Lost Dropdownlist....just &nbsp

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
 
S

Sean Chambers

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
 
B

bruce barker \(sqlwork.com\)

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top