GridView1_RowUpdating无效。 。 [英] GridView1_RowUpdating is not working. .
本文介绍了GridView1_RowUpdating无效。 。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有模板字段的网格,其中包括项目模板和编辑项目模板。
编辑任何一行时没有在字符串(城市)中显示更新的值。
请帮助我
I have a grid with template fields which includes item templates and edit item templates.
While editing any row it is not showing updated value into the string(city).
Please help me
string id = ((Label)GridView1.Rows[e.RowIndex].FindControl("Label4")).Text;
string city = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox3")).Text;
推荐答案
//for example see this
//in gridview put this property
// DataKeyNames="Id"
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];
int id = Int32.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString());
Label id = (TextBox)row.FindControl("Label4");
TextBox city = (TextBox)row.FindControl("TextBox3");
SqlCommand cmd = new SqlCommand("update query ", con);
//for example of update query
//update tablename set column=city.text where id=convert.toint16(id.text) ;
con.Open();
cmd.ExecuteNonQuery();
GridView1.EditIndex = -1;
bind();
}
string city =(TextBox)GridView1.Rows [e.RowIndex] .FindControl(TextBox3);
试试这个
string city = (TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox3");
Try this
这篇关于GridView1_RowUpdating无效。 。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文