Click to See Complete Forum and Search --> : HELP ME!! Bug problem or just me?? HELP ME!!


scottie_uk
April 20th, 2003, 12:34 PM
I am developing a form with a drop down list containing items loded in from a data base.

The user will click on a n item in the DDL the click a button to delete it.

I have ben using

ddlAccomodationList.selectedItem.text

when the delete comand is selected it only returns the first item in the list, what ever I select.

If I set enableViewState to True, this solves the problem, but then means when the page is reloaded/refreshed, I get duplicate items in the list.

to re-load a page i redirect it to it's self using the below code:

responce.redirect(website.aspx)


Please help me I am in dire need.


:confused: :confused:

V. Lorenzo
April 25th, 2003, 12:10 PM
In order to make the items in the list selectable you have :

1- First, the list must be viewstate enabled.
2- Second, the list items 'Value' property must be unique. You have to manage it so all the items have a unique value, or you will be able to select only the first with that value from the list (don't know exactly why, but...)
3- And third, you must fill the list only once, or the selection the user made will be lost (this default behaviour may be overriden).

Maybe you are trying to fill the list each time you load the page. In that case you just need to check if the page is being create due to a postback or an original request.

If you fill the list in the page's Init (or Load) event handler, just do this :

if (!this.IsPostback)
{
...do the list filling...
}

if it is done in a control...
if (!this.Page.IsPostback)
{
...do the list filling...
}

That's all.

VLorz