Lost Dropdownlist....just &nbsp

  • Thread starter Thread starter OJ
  • Start date Start date
O

OJ

Hi,
ASP.NET C# 2.0

I have a usercontrol which contains a Gridview. I create my own
DataTable to bind to the GridView, which then fires the RowDataBound
event of the the Gridview. Here I add a dropdownlist to the relevent
row.Cell. I then expose the GridView as a public property of the
usercontrol. This all works lovely. However, when I try to find the
dropdownlist by accessing the GridView property of the usercontrol on
the ASP next page, the dropdownlist does not appear to be there. The
cell in which it **should** reside has no control count, and a Text
property of " ". All the other data is accessible through the
Rows[x].Cells[y].Text property.

Does anybody recognise this behaviour and might suggest what I am
inevitabley doing wrong in this scenario?

Thanks,
OJ
 
I wonder if the RowDataBound event is too late to add controls to the
gridview cells. I am not positive though, but I think this might be the
case.

I am interested to see a solid response.

Sean
 
you need to add the dropdown control on postback in the onint event. if you
use dynamic control, all work shoudl be done in onint not formload. form
load is for access controls after they are created, and received their
postback values. as a general pratice, you should not set form control
values in form load nor add any controls.

-- bruce (sqlwork.com)
 
Back
Top