|
Question : Retrieving info from DropDownList on OnSelectedIndexChanged in a repeater
|
|
Hey folks!
I've become flummoxed by something very unusual which I've never come across before and I really would like some urgent help to fix the problem.
I have a repeater control which contains a DropDownList containing dynamically generated values. The DropDownList has the following attributes: AutoPostback = true OnSelectedIndexChanged = ddlQty_Changed
In my page load, I check if the page is a postback first, before doing a databind. If there was a page postback, then there is no databind.
Once the the ddlQty is hit, the sender is the first item in the repeater, and the selected index is zero (even if I change the selection of the fifth item to a selected index of something like 4.
I've looked around and most solutions point to the following: Make sure that EnableViewState is true (which it is) Do not bind the data again if the page is loading as a result of a postback (which I'm not).
I've tried it many different ways, and the closest I've managed to get is: At the top of the page_load method, check if the page is a postback. If it is, get the postback control name (http://geekswithblogs.net/mahesh/archive/2006/06/27/83264.aspx). If the control is ddlQty, then get the postback control (http://www.eggheadcafe.com/articles/20050609.asp). Fire a method which does something with the newly gotten control. Cast the control as a dropdownlist.
The newly created dropdownlist does have the correct repeateritem dropdownlist, but the selected index of this control is set to zero.
Either way, that (to me) is a very dodgy way of dealing with postback events, and it seems that it doesn't work correctly anyway.
Can anyone help me with this at all?
Thanks in advance.
|
|
Answer : Retrieving info from DropDownList on OnSelectedIndexChanged in a repeater
|
|
PAQed with points refunded (500)
Computer101 EE Admin
|
|
|
|