We help IT Professionals succeed at work.

ASP.NET Bind DropDown within GridView but Selected Value lost after submit_click

lanter007
lanter007 asked
on
2,284 Views
Last Modified: 2011-04-14
Hi experts,
Depending on a GridView_DataBound event I generate a new DropDownList:

Protected Sub GridView2_DataBound...

lblBestellteTickets.Text = GridView2.Rows.Count

Dim bestellteTickets As Integer = lblBestellteTickets.Text
_FreieTickets = _TotalTickets - bestellteTickets

Dim i
For i = 1 To _FreieTickets
 lstTickets.Items.Add(New ListItem(i, i))
Next i
......


And then the user can select one option and submit it with a submit-Button:

Protected Sub btnRes_Click....

Dim counter As Integer = lstTickets.SelectedItem.Value

Depending on the selectedValue I will do something like this.

Dim i
For i = 1 To counter.........


But I lose the selected value. What are I doing wrong?

Thanks for your help.
lanter007
Comment
Watch Question

CERTIFIED EXPERT

Commented:
I believe it is lstTickets.SelectedValue which will give you the value.

Author

Commented:
No, I tried but it always shows the first Value 1.
CERTIFIED EXPERT

Commented:
Tell me what you're trying to do in plain English as your code doesn't make sense.

This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.