Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Comments
Sinisa Hajnal 23-Sep-14 2:11am    
Unable how? You don't see them? You get an error?
C# is case sensitive (stupid feature) so row.cells is different from Row.Cells. Try that, maybe it helps.

1 solution

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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900