|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How Do I assign an ID to ListItem?How can I assign an ID to dynamically generation ListItem that I add to
dynamically generated CheckBoxList or RadioButtonList? I need to identify the specific ListItem later through Request.Form when user sends back data. Replied in already in buildingcontrols
=========================== ListItem doesn't have an ID, it's not deriving from control so it cannot have ID. Instead, you'd need to search the ListItem from ListItemCollection (Items property) with the value that was posted. Dim litem As ListItem= lst.Items.FindByValue(Request.Form("returnsvaluetolookfor")). where lst is the control having the ListItem to look for. ========================== -- Show quoteHide quoteTeemu Keiski ASP.NET MVP, AspInsider Finland, EU "Amelyan" <bamel***@wi.rr.com> wrote in message news:%23WkOUNORFHA.688@TK2MSFTNGP10.phx.gbl... > How can I assign an ID to dynamically generation ListItem that I add to > dynamically generated CheckBoxList or RadioButtonList? I need to identify > the specific ListItem later through Request.Form when user sends back > data. > I need to identify ListItem of dynamically generated CheckBoxList with
Request.Form. I originally tried to set CheckBoxList.ListItem.Value to something, but the value never gets rendered into html. Instead, the Value gets set to "on", if user checked the CheckBoxList.ListItem. You can try it by dynamically creating CheckBoxList. There is no way to identify which CheckBoxList.ListItem was selected through Request.Form. This is why I decided that maybe there is a way to set ID, or any other way to identify ListItem by other then ListItem.Text. Thanks, Amelyan Show quoteHide quote "Teemu Keiski" <jot***@aspalliance.com> wrote in message news:uvHc9VPRFHA.1500@TK2MSFTNGP09.phx.gbl... > Replied in already in buildingcontrols > > =========================== > ListItem doesn't have an ID, it's not deriving from control so it cannot > have ID. Instead, you'd need to search the ListItem from > ListItemCollection > (Items property) with the value that was posted. > > Dim litem As ListItem= > lst.Items.FindByValue(Request.Form("returnsvaluetolookfor")). > > where lst is the control having the ListItem to look for. > > ========================== > > -- > Teemu Keiski > ASP.NET MVP, AspInsider > Finland, EU > > "Amelyan" <bamel***@wi.rr.com> wrote in message > news:%23WkOUNORFHA.688@TK2MSFTNGP10.phx.gbl... >> How can I assign an ID to dynamically generation ListItem that I add to >> dynamically generated CheckBoxList or RadioButtonList? I need to >> identify the specific ListItem later through Request.Form when user sends >> back data. >> > > Hi Amelyan,
Not sure why you want to use Request.Form. Can you not use code-behind? I presume you are using code-behind to dynamically populate the checkboxlist? You could use code-behind to do something like this: dim myitem as listitem for each myitem in chkboxlist.items if myitem.selected then dim myvar as int32 = ctype(myitem.value, int32) end if next Obviously, the above would be a problem for more than one selection, but gives an idea. If this doesn't help, would need more info as to what you are doing (eg, how are you populating the checkboxlist?) Regards, Mark St Denis Show quoteHide quote "Amelyan" wrote: > > I need to identify ListItem of dynamically generated CheckBoxList with > Request.Form. I > originally tried to set CheckBoxList.ListItem.Value to something, but the > value never gets rendered into html. Instead, the Value gets set to "on", > if user checked the CheckBoxList.ListItem. You can try it by dynamically > creating CheckBoxList. There is no way to identify which > CheckBoxList.ListItem was selected through Request.Form. This is why I > decided that maybe there is a way to set ID, or any other way to identify > ListItem by other then ListItem.Text. > > Thanks, > Amelyan
Uncheck Checkboxes
Repeat web controls in ASPX page DataList ERROR URGENT Open New Window Server Side How do you populate the Dropdown in IE Web Controls? Creating a 3 State Rollover Button Developing .NET Custom Web Control for use in ASP & ASP.NET pages DataGrid Question - asp:Hyperlink Sorting problem in DataGrid Color Picker Control |
|||||||||||||||||||||||