Save value from the combobox for the index that will be changed.

For e.g: If I have 5 items listed and 1st one is selected and when I change index to suppose 4th one, I need to save the value of 1st listed item at time of index being changed and next time if I select 2nd item on the list it needs to save value for 4th one at time of index change.

I need to pass that value for batch name in the below listed stored procedure every time index is changed so that previous selected index can be unlocked.

cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "usp_CAMR_UnlockedBatchName";
                    cmd.Parameters.AddWithValue("@Batch_Name", temp);
                    cmd.Parameters.AddWithValue("@lst_mod_userid", Environment.UserName);

Recommended Answers

All 3 Replies

Have a look at the selectedvaluechanged event.

SelectedIndexChanged event of combobox is unable to help you as if you try to get the SelectedText value in a SelectedIndexChanged or SelectedValueChanged event handler, the property returns an empty string. This is because, at the time of these events, the previous SelectedText value has been cleared and the new value has not yet been set.

Keep track of "SelectedIndex" property in "SelectedIndexChanged" event handler.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.