Re: how to get selected values ( vb.net )

From: Joel Cade (joel_at_nospam.figtreesolutions.com)
Date: 10/20/04


Date: Wed, 20 Oct 2004 13:45:02 -0700

You could, do something like this in your page load

If Page.IsPostBack Then
        Dim li As ListItem
        Dim oControl As Control

        For Each li in pytania_list.Items
                For Each oControl In li.Controls
                        If TypeOf Control Is RadioButtonList Then
                                ' Do Something.
                        End If
                Next
        Next

End If

Hope this helps,

Joel Cade, MCSD
Fig Tree Solutions, LLC
http://www.figtreesolutions.com

"krzysiek" wrote:

> Thanks a lot for your advise Saravana, however i have little bit different
> case.
> I have 3 types of webcontrols that are nested in DataList.
>
> **************************
> <asp:DataList OnItemDataBound="odp_bound" id="pytania_list" runat="server"
> Width="100%" >
> <ItemTemplate>
> <table width="100%" >
> <tr><td >
> <asp:CheckBoxList id="box" runat="server"
> ></asp:CheckBoxList>
> <asp:TextBox id="TextBox1" runat="server"
> visible="false"></asp:TextBox>
> <asp:RadioButtonList id="RadioButtonList1"
> runat="server"></asp:RadioButtonList>
> </td></tr>
> </table></ItemTemplate></asp:DataList>
> **************************
> when DataList is bound it trrigers proc. "odp_bound" which drowing controls
> based on database data.
>
> **************************
> sub odp_bound(s As Object, e As DataListItemEventArgs)
> If e.Item.ItemType = ListItemType.Item Or _
> e.Item.ItemType = ListItemType.AlternatingItem Then
> If Not e.Item.DataItem Is Nothing Then
>
> select case e.Item.DataItem("rodzaj")
> case="4"
>
> dim radio as RadioButtonList =
> e.Item.Findcontrol("RadioButtonList1")
>
> Dim dr As DataRowView = CType(e.Item.DataItem,
> DataRowView)
> dim dv as Dataview
> dv=dr.CreateChildView("PytaniaOdpowiedzi")
> radio.DataSource = dv
> radio.DataTextField="tresc"
> radio.DataBind()
> (.....)
> ***************
>
> after postback i should get valuses of all previously generated controls
> but i dont know how to loop through those controls..
> Your LoopingControls sub looks fine but i don't know what event can run
> it..
>
> thanks 4 any advise :-)
>
>
>
>
>
>
>
>
> "Saravana" <saravank@sct.co.in> wrote in message
> news:3Ztdd.1207$N47.1191@news.cpqcorp.net...
> > You loop through each control in the page and check that control type. If
> it
> > is checkbox or radiobuttonlist then you can get the selected value of that
> > control. To know how to loop through controls in a page, check out this
> > article
> > http://www.extremeexperts.com/Net/Articles/LoopingthroughControls.aspx
> >
> >
> > "krzysiek" <krzysiek79pl@hotmail.com> wrote in message
> > news:cl5i8u$2qio$1@news2.ipartners.pl...
> > > hello,
> > > i have several radiolists and checkboxlist that are generated dinamicly
> > > based on datasource. So frankly speaking i don't know names and number
> of
> > > that web controls cose they are always different.
> > > How can i retreive selected values from those controls ?
> > >
> > >
> >
> >
>
>
>