就是我要做一个gridview里加了一个boundfield和一个templatefield,其中boundfield邦定的是客户名称,templatefield的itemfield里拖了一个button的控件,想实现 的功能是点击这个button可以查看对应客户的项目名称,但是我不知道是在button引发的事件里写还是在gridview的某个事件里写。我就是不知道应该在哪个事件里谢谢大家。
调试欢乐多
{
string ConnectionString = "Data Source=localhost;Initial Catalog=abs;Persist Security Info=True;User ID=sa;Password=123";
SqlConnection cn = new SqlConnection(ConnectionString);
SqlDataAdapter sda1 = new SqlDataAdapter("select projectName from [clientProject] where clientID = @clientID", cn);
sda1.SelectCommand.Parameters.Add("@clientID", SqlDbType.Int).Value = Convert.ToInt32(GridView1.DataKeys[e.Row.RowIndex].Value);
DataSet dr1 = new DataSet();
cn.Open();
sda1.Fill(dr1);
DataRow dr;
dr = dr1.Tables[0].Rows[0]; cn.Close();
Response.Redirect("~/Default2.aspx?clientID=" + Convert.ToString(dr["clientID"].ToString()));
}