Link to home
Create AccountLog in
Avatar of Stephan_Schrandt
Stephan_SchrandtFlag for Germany

asked on

Webusercontrol in gridview which event to bind dropdownlist

Hello,

i have created a webusercontrol that holds a dropdownlist. Normally you would bind the dropdown to the data in the page_load event of webusercontrol, something like:

Sub Page_Load()
  If not me.IsPostBack Then
    FillDropDown
  End IF
End Sub

Now the problem:

I want to use the control in an edititemtemplate of a gridview. By clicking on the edit link, the controls page_load triggers, but me.IsPostBack is true. I understand why this happens, my question is, what event do I have to use to fill the dropdown in order to get it work with the gridviews edititem?

Thank you
SOLUTION
Avatar of Jerry Miller
Jerry Miller
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Stephan_Schrandt

ASKER

Thank you for your answer. I would like to handle the filling of the dropdown in the control itself, not from the outside. I tried putting it into New() and Prerender() but the problem is, the child controls of the webusercontrol do not exist at this time. Ensurechildcontrols does not work either.
I tried your suggestion and ended up with a new problem:

http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_27933937.html


I had to use rowcreated event before databinding, but that shouldn't matter
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
In my solution I assume the behaviour only happens in Databound containers. Maybe it won't work in other containers