Listbox on Postback

D

Danno

Ok, I'm losing my mind. I have a simple ASP.NET page with a listbox
control. I am loading the listbox with a few items during Page_Load,
but only if it is NOT postback (the listbox is unbound, the items come
from XML).

I select an item from the list and click a Delete button, but on
postback the SelectedIndex property is always = 0 (unless I don't
select an item and then I get -1).

EnableListView is true for the page and the listbox.

Any ideas?
 
P

Praveen Naregal

Even I am facing the same problem. EnableViewState is true.
What might be the problem?
-----Original Message-----
viewstate is on?

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
Danno said:
Ok, I'm losing my mind. I have a simple ASP.NET page with a listbox
control. I am loading the listbox with a few items during Page_Load,
but only if it is NOT postback (the listbox is unbound, the items come
from XML).

I select an item from the list and click a Delete button, but on
postback the SelectedIndex property is always = 0 (unless I don't
select an item and then I get -1).

EnableListView is true for the page and the listbox.

Any ideas?


.
 
D

Danno

Yeah, sorry. I meant to say EnableViewState (not EnableListView) is
on for the form and listbox.

Alvin Bruney said:
viewstate is on?

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
Danno said:
Ok, I'm losing my mind. I have a simple ASP.NET page with a listbox
control. I am loading the listbox with a few items during Page_Load,
but only if it is NOT postback (the listbox is unbound, the items come
from XML).

I select an item from the list and click a Delete button, but on
postback the SelectedIndex property is always = 0 (unless I don't
select an item and then I get -1).

EnableListView is true for the page and the listbox.

Any ideas?
 
A

Alvin Bruney [MVP]

post a short but complete program which demonstrates this problem

use this as a guide
http://www.yoda.arachsys.com/csharp/complete.html
--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
Danno said:
Yeah, sorry. I meant to say EnableViewState (not EnableListView) is
on for the form and listbox.

Alvin Bruney said:
viewstate is on?

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
Danno said:
Ok, I'm losing my mind. I have a simple ASP.NET page with a listbox
control. I am loading the listbox with a few items during Page_Load,
but only if it is NOT postback (the listbox is unbound, the items come
from XML).

I select an item from the list and click a Delete button, but on
postback the SelectedIndex property is always = 0 (unless I don't
select an item and then I get -1).

EnableListView is true for the page and the listbox.

Any ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top