[英]SeletedIndexChange event of GridView is not firing in asp.net?
The following code is not executing!! 以下代码未执行!
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow r = GridView1.SelectedRow;
TxtName.Text = r.Cells[0].Text;
TextBox2.Text = r.Cells[1].Text;
TextBox3.Text = r.Cells[2].Text;
TextBox4.Text = r.Cells[3].Text;
}
You must use EnableViewState="true"
and bind just one time with ! IsPostBack
您必须使用
EnableViewState="true"
并使用绑定一次! IsPostBack
! IsPostBack
in order to not erase your event foreach post. ! IsPostBack
以便不删除每个帖子的事件。
because when your re build your grid you erase all events 因为当您重新构建网格时,您会擦除所有事件
In your page load : 在您的页面加载中:
if(! IsPostback)
{
//Bind your Gridview
}
Persist your datas with EnableViewState="true"
使用
EnableViewState="true"
保留数据
<asp:gridview id="YourGridView" EnableViewState="true" ...../>
我们需要启用选择按钮,然后仅触发GridView1_SelectedIndexChanged,即AutoGenerateSelectButton =“ true”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.