我的DataGrid控件没有用模板,下面这个方法我也用不成,因为我是对叶面上的一个Button空间点击事件中写的代码。
private void DataGrid1_UpdateCommand(object source,System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string categoryName, categoryDescription; // Gets the value of the key field of the row being updated
string key = DataGrid1.DataKeys[e.Item.ItemIndex].ToString(); TextBox tb = (TextBox)(e.Item.Cells[2].Controls[0]);
categoryName = tb.Text;
}下面是我的点击事件,又一个Button触发
private void BtnNextPage_Click(object sender, System.EventArgs e)
{
//运行存储过程,返回SQLDataReader
DataSet ds = new DataSet();
SqlConnection myConnection = new SqlConnection(DbConnetionString);
SqlCommand cmd=new SqlCommand("pageTest",myConnection);
cmd.CommandType=CommandType.StoredProcedure;
cmd.Parameters.Add("@bm_name2",DropDownList1.SelectedValue);
string aa=DataGrid1.Items[0].Cells[9].Text;//这里有错误,应该怎么写?
cmd.Parameters.Add("@LastID",aa);
.............
}
private void DataGrid1_UpdateCommand(object source,System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string categoryName, categoryDescription; // Gets the value of the key field of the row being updated
string key = DataGrid1.DataKeys[e.Item.ItemIndex].ToString(); TextBox tb = (TextBox)(e.Item.Cells[2].Controls[0]);
categoryName = tb.Text;
}下面是我的点击事件,又一个Button触发
private void BtnNextPage_Click(object sender, System.EventArgs e)
{
//运行存储过程,返回SQLDataReader
DataSet ds = new DataSet();
SqlConnection myConnection = new SqlConnection(DbConnetionString);
SqlCommand cmd=new SqlCommand("pageTest",myConnection);
cmd.CommandType=CommandType.StoredProcedure;
cmd.Parameters.Add("@bm_name2",DropDownList1.SelectedValue);
string aa=DataGrid1.Items[0].Cells[9].Text;//这里有错误,应该怎么写?
cmd.Parameters.Add("@LastID",aa);
.............
}
Label2.Text=myDataSet.Tables["HZBB_CJZZPQDZ_Query"].Rows[myDataSet.Tables["HZBB_CJZZPQDZ_Query"].Rows.Count-1]["GZPZ_Id"].ToString();private void BtnNextPage_Click(object sender, System.EventArgs e)
{
SqlCommand cmd=new SqlCommand("pageTest",myConnection);
cmd.CommandType=CommandType.StoredProcedure;
cmd.Parameters.Add("@LastID",Label2.Text);。
}