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!
Sreejith Ram - 19 Oct 2005 17:40 GMT
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();
}
> 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
[quoted text clipped - 12 lines]
>
> Any ideas?! Thanks in advance!
runtoofar@gmail.com - 19 Oct 2005 19:01 GMT
Thanks, I knew it was something simple. Too bad I wasted many hours on
a complex solution not needed!
Scott Allen - 20 Oct 2005 13:30 GMT
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.
--
Scott
http://www.OdeToCode.com/blogs/scott/
>Thanks, I knew it was something simple. Too bad I wasted many hours on
>a complex solution not needed!