在Asp.net的gridview的rowdatabound事件中无法访问在Rowcreated事件中创建的控件 [英] Controls created in Rowcreated event is not accessible in rowdatabound event of gridview in Asp.net

查看:90
本文介绍了在Asp.net的gridview的rowdatabound事件中无法访问在Rowcreated事件中创建的控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI
我在gridview的Rowcreated事件中动态创建了一些控件,当我尝试从rowdatabound事件中访问它时,它们无法访问



I在rowcreated事件中创建了以下控件



GridviewRowcreatedevent()

{

if(e.row.rowtype == DataControlRowType.Datarow)

{

Imagebutton ibtn = new imagebutton();

ibtn.text =edit;

e.row.Cells [0] .Add(ibtn);



Textbox txt1 = new Textbox();

e.row.cells [1] .Add(txt1);



Textbox txt2 = new Textbox();

e.row .cells [2]。添加(txt2);

}

}



但我能够只访问放置在单元格[0]中的控件,并且无法从rowdatabound事件访问单元格[1],单元格[2]控件。我无法找出它的问题。任何人都可以解决这个问题。





谢谢

Santhosh

HI I have created some controls in Rowcreated event of gridview dynamically and when i try to access it from rowdatabound event they are not accessible

I have created following controls in rowcreated events

GridviewRowcreatedevent()
{
if(e.row.rowtype==DataControlRowType.Datarow)
{
Imagebutton ibtn =new imagebutton();
ibtn.text="edit";
e.row.Cells[0].Add(ibtn);

Textbox txt1=new Textbox();
e.row.cells[1].Add(txt1);

Textbox txt2=new Textbox();
e.row.cells[2].Add(txt2);
}
}

but i am able to access only the control which is placed in cell[0], and Cells[1],cell[2] controls are not accessible from rowdatabound event. i am unable to find out the problem of it. can any one please solve this.


Thank you
Santhosh

推荐答案

我没有在行绑定事件中编写代码,而是在条件语句中创建了行创建事件中的代码,但是我的设计略有改动。



谢谢
Instead of writing the code in row bound event i wrote the code in row created event in conditional statements, that worked.but my design altered slightly.

Thank you


这篇关于在Asp.net的gridview的rowdatabound事件中无法访问在Rowcreated事件中创建的控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆