⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 editstuinfo.ascx.cs

📁 this is code for all person who want ro larn vb
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class controls_editStuinfo : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["stu_id"] == null)
            Response.Redirect("~/Default.aspx");
        else

        if(!IsPostBack)
         fillData();
    }
    public void fillData()
    {
        SqlConnection conn = new SqlConnection();
        conn.ConnectionString = connection.getconnection;
        SqlDataAdapter ad = new SqlDataAdapter("SELECT [stu_id], [stu_name], [stu_major], [address], [email], [phone], [stu_year], [stu_pass], [cv_doc] FROM [students] WHERE ([stu_id] = @stu_id)", conn);
        SqlParameter p=  ad.SelectCommand.Parameters.Add("@stu_id", SqlDbType.VarChar);
        p.Value = Session["stu_id"].ToString();
        DataSet ds = new DataSet();
        ad.Fill(ds);
        if (ds.Tables.Count > 0)
        {
            txtid.Text = ds.Tables[0].Rows[0][0].ToString();
            txtname.Text = ds.Tables[0].Rows[0][1].ToString();
            txtmajor.Text = ds.Tables[0].Rows[0][2].ToString();
            txtaddress.Text = ds.Tables[0].Rows[0][3].ToString();
            txtmail.Text = ds.Tables[0].Rows[0][4].ToString();
            txtphone.Text = ds.Tables[0].Rows[0][5].ToString();
            txtyear.Text = ds.Tables[0].Rows[0][6].ToString();
            
        
        }


    
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string fn = "not found";
        string loc = "";
        if (FileUpload1.PostedFile != null && FileUpload1.PostedFile.ContentLength > 0)
        {
            fn = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName);
            loc = Server.MapPath("~/cvs");
            FileUpload1.PostedFile.SaveAs(loc + "/" + fn);


        }


        SqlDataSource1.UpdateParameters[8].DefaultValue = txtid.Text;
        SqlDataSource1.UpdateParameters[0].DefaultValue = txtname.Text;

        SqlDataSource1.UpdateParameters[1].DefaultValue = txtmajor.Text;
        SqlDataSource1.UpdateParameters[2].DefaultValue = txtaddress.Text;
        SqlDataSource1.UpdateParameters[3].DefaultValue = txtmail.Text;
        SqlDataSource1.UpdateParameters[4].DefaultValue = txtphone.Text;
        SqlDataSource1.UpdateParameters[5].DefaultValue = txtyear.Text;
        SqlDataSource1.UpdateParameters[6].DefaultValue = txtpass.Text;
        SqlDataSource1.UpdateParameters[7].DefaultValue = fn;
        SqlDataSource1.Update();
        fillData();


    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -