Hello Joel,
Thanks 4 your support. Your code looks pretty simple that's why i deployed
it immediatelly but :-( i didn't mention that my DataList "pytania_list" is
also nested in another master DataList which is called "ankieta_list". So
following your e.g. i wrote:
Dim li As ListItem
Dim oControl As Control
dim ankieta_list as DataList = Findcontrol("ankieta_list")
Dim item As DataListItem
For Each item in ankieta_list.Items
For Each oControl In item.Controls
If TypeOf oControl Is DataList Then
dim pytania_list as DataList = oControl
Dim pyt_item As DataListItem
Dim ctrl As Control
For Each pyt_item in
pytania_list.Items
For Each ctrl In
pyt_item.Controls
If TypeOf ctrl Is
TextBox Then
do somth...
end if
next
next
End If
next
Next
.... and it works !! :-)
Thanks a lot Joel !!
"Joel Cade" <jo**@nospam.figtreesolutions.com> wrote in message
news:90**********************************@microsof t.com...
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" <sa******@sct.co.in> wrote in message
news:3Z*****************@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/Ar...hControls.aspx
"krzysiek" <kr**********@hotmail.com> wrote in message
news:cl***********@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 ?
>
>