[RESOLVED] Dropdownlist is empty when web page displays

 A web site project, 4 pages.  First page just has button links to redirect to another page. When button link is cliced,  the data is retrieved from SQL Server through stored procedures and they are in a class file.  Able to call the procedures and pass the information through SET Properties and right before the page is displayed, checked and data is in the dropdownlist control then redirect to show page.  The dropdowlist is empty, should I be using something different to show the page with the data?  Have tryied REDIRECT and then fill dropdownlist and its still empty on displayed.

Thanks for any help.

Show your codes please.

At which page did you get the data? If you want them to be displayed in second page, then you need to do data bind on this page. Or, you can pass the data got in the first page as session passed to the second page. 

UndecidedLatest code:

From 1st Page

Response.Redirect(http://localhost:2467/OIA%20Email%20Maintenance%20Web/EmailRecipient.aspx)

 

On 2nd Page in LOAD:

Me.pasEmailMaintenance.getAutoNoticeKeyInfo(0)                                (from Class file)

Me.ddlAutoNoticeKey = Me.pasEmailMaintenance.AutoNotice             (from Class file)

At this point checked ddl.AutoNoticeKey.Items(0).Value and does have a value.

 

 

 

Please can someone help me with this. 

not sure what this class is Me.pasEmailMaintenance.AutoNotice    and is Me.ddlAutoNoticeKey you dropdownlist name?  

Me.ddlAutoNoticeKey.items.add(new system.web.webcontrols.listitem("display value", "key value")) is the way to add to a drop down

have you tried running debugger and see if your AutoNotice has any type of value?                  

Me.pasEmailMaintenance.AutoNotice is dropdownlist populate from a stored procedure in class file. Using the AutoNotice to populate ddlAutoNoticeKey which is the dropdownlist on the page. Use a class file because retrieve this information will be used on more that one page. I update the ddlAutoNoticeKey in the Page_Load. Right after that I checked by messagebox and using a random index and did get the data, but no data when the page displayed. Now that I changed the code by adding items way Lorddog suggested and now when message box displays it just says OK.

I am newbie to ASP.net.

I finally got it, I had

Me.ddlAutoNoticeKey.DataSource = Me.pasEmailMaintenance.AutoNotice

and what I needed was:

Me.ddlAutoNoticeKey.DataSource = Me.pasEmailMaintenance.AutoNotice.Items

thoughts on "[RESOLVED] Dropdownlist is empty when web page displays"

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>