gridview里面我定义了一个bind();代码: public void bind()
{
string sqlstr = "select classroom_id,classroomname,addressname,number,time01,time02,time03,time04,time05,time06,time07,time08,time09,time10,time11,time12,time13,time14,time15,time16,beizhu from ds_classroom";
SqlConnection objconn;
objconn = new SqlConnection(ConfigurationSettings.AppSettings["connstr"]);
SqlDataAdapter myda = new SqlDataAdapter(sqlstr, objconn);
DataSet myds = new DataSet();
objconn.Open();
myda.Fill(myds, "ds_classroom");
GridView1.DataSource = myds;
GridView1.DataKeyNames = new string[] { "classroom_id" };//主键
GridView1.DataBind();
objconn.Close();
}
但是在public void btnAdd_Click()里面使用bind()并不能对gridview实现操作,请问如何将外部按钮,外部函数btnAdd_Click()绑定到gridview里面,注意:gridview里面的数据是从bind()里面实现绑定的.等待大家的答案,谢谢大家的帮助~~~