本文介绍了在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

HII 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

推荐答案


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

10-29 12:23