110,534
社区成员
发帖
与我相关
我的任务
分享
protected void LinkButton1_Click(object sender, EventArgs e)
{
string sid;
sid = ((LinkButton)sender).CommandArgument.ToString(); //这里获取到ID,已经测试输出sid的值为该行ID
string sql;
SqlConnection myconn;
SqlCommand mycommand;
myconn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbs"].ConnectionString);
sql = "select tname from users where id = '" + sid +"'" ;
mycommand = new SqlCommand(sql, myconn);
myconn.Open();
SqlDataReader aaa = mycommand.ExecuteReader();
Response.Write(aaa);
}