ASCX User Control Drop Down List Issues

  • Thread starter Thread starter runtoofar
  • Start date Start date
R

runtoofar

I have an ASCX user control with a drop down list inside an ASPX (C#)
page. The user selects an item from the DDL, clicks a button, and the
DDL.SelectedValue is supposed to be sent to another function. However,
the SelectedValue is always the first value in the DDL. I have tried
several methods to work around this including the examples at:

http://www.mastercsharp.com/article.aspx?ArticleID=67&&TopicID=2
http://odetocode.com/Articles/116.aspx

Everytime however no matter what method is used, I cannot get the true
SelectedValue of the drop down list.

All the functions required are inside the ASCX page, there is nothing
needing to be called in the parent ASPX or C# code-behind.

Any ideas?! Thanks in advance!
 
Have you checked If the databinding happening in all postbacks?
The code in Page_load of control should be like below

if(!Page.IsPostBack())
{
yourDDl.datasource =something;
yourDDl.DataBind();
}
 
Thanks, I knew it was something simple. Too bad I wasted many hours on
a complex solution not needed!
 
Do you have an event handler for the drop down list's SelectionChanged
event? That would be an ideal spot to pick up the new value - I'm not
sure how data binding will help.
 
Back
Top