1. 首先在.aspx文件中给转换为控件的新增列绑定字段,然后才能在.cs文件中调用它的值。
2. 在.cs文件中,用 ((LinkButton)sender).CommandArgument.ToString() 这个语句来调用带过来的值。
3. LinkButton1_Click函数的写法如下:
protected void LinkButton1_Click(object sender, EventArgs e)
{
SqlConnection myconn;
myconn = new SqlConnection(ConfigurationManager.ConnectionStrings["JlyConnectionString"].ConnectionString);
myconn.Open();
SqlCommand myCMD = new SqlCommand("update ClientTable set IsDelete=1 where ClientID=" + ((LinkButton)sender).CommandArgument.ToString(), myconn);
SqlDataReader myReader = myCMD.ExecuteReader();
//GridView的数据源重新邦定一下。相当于刷新。
string res = "SELECT ClientID, ClientName, ClientPassword, ClientTrueName, ClientEmail, ClientSex, ClientAge, ClientIntro, ClientMemo, IsPass, IsDelete FROM ClientTable WHERE (IsPass = 0) and (IsDelete=0) Order by [ClientID] Desc";
SqlDataSource1.SelectCommand = res;
GridView1.DataSourceID = "SqlDataSource1";
GridView1.DataBind();
}