[RESOLVED] After submission, the value from the Listbox is incorrect.
I have this code inside of my button's event. The problem I am having is that the text input into the database is always the text from the first index of the listbox named categoryLst. I even used a listbox selection change event to change the text whenever the listbox was changed. But that became a lot more code and it still didn't work. I still get whatever is first in the list. I don't understand why this is happening. I am thinking it's a timing issue of some kind.
Code:
comm.Parameters.Add("@Relation", System.Data.SqlDbType.NVarChar, 20);
comm.Parameters["@Relation"].Value = categoryLst.SelectedItem.Text;
I need some help figuring out how I can get the text from the selection made, not the first one in the list. It's stuck and not changing for me when processing code. The user can change the selection in the list box and then hit the submit button. What is going on?
Re: After submission, the value from the Listbox is incorrect.
You need to show more code for the part of submit button click
Re: After submission, the value from the Listbox is incorrect.
Can you show the code of the submit button?
EDIT: Oops, too late. ;)
Re: After submission, the value from the Listbox is incorrect.
Using Page.IsPostBack solves the problem of accidentally rebinding the data and setting the list box back to it's default index.