473,414 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

how to get selected values ( vb.net )

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 ?
Nov 18 '05 #1
4 6525
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 ?

Nov 18 '05 #2
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 ?


Nov 18 '05 #3
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 ?



Nov 18 '05 #4
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 ?
>
>


Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Vipin Kedia | last post by:
Hi I have written a code for showing the list boxes as selected using a Listitem and the selected property of the items. Now I have 2 list boxes in my page. But it shows only the selected values...
4
by: Dan | last post by:
Can anyone offer suggestions on how to do this or if it is possible? I have a form that uses a drop down box and 2 text fields. What I am trying to do is have the value of each text box set by...
1
by: smash2004 | last post by:
I want to keep selected values in select list when i click on another option...with a click on a mouse... if i have 3 options in select list and i click first option..it gets selected..if i then...
5
by: Elvis V. | last post by:
Good morning, I have a table with three fields, Buildings, Floors and Rooms. This is what I would like to do; in my form when I select Building1 in my drop down box for Buildings, when I go to the...
2
by: Stephen Miller | last post by:
When I dynamically populate a HtmlSelect combo box, the Value property consistently fails to return the item selected, defaulting instead to the first item in the list. For example: Protected...
4
by: juststarter | last post by:
Hello, I have an aspx file where i've put a placeholder element. On load (page_load) i create dynamically an html table which contains a checkbox and a radiobuttonlist in each tablerow . The...
2
by: John | last post by:
I have a listbox that is databound when my form loads. A user can then select and option using a drop down box. When the user selects an option the corresponding items in the listbox gets selected....
2
by: mumbaimacro | last post by:
hi i have two combo boxes in a form with values from a table. i need a report to be opened by a button from the form ,The Report should show the values selected in the combo boxes in the form...
6
by: yasodhai | last post by:
Hi, I used a dropdown control which is binded to a datagrid control. I passed the values to the dropdownlist from the database using a function as follows in the aspx itself. <asp:DropDownList...
9
by: ajos | last post by:
Hello friends, After thinking about this for sometime, i decided to post this in the java forum. Well my problem here in detail is, i have 3 jsp pages where in a.jsp(for example) i have a combo...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.