[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webcontrols

postback ... get checked checkbox

Tony Fabian

1/15/2003 10:48:00 PM

Hi



I am creating an order form which hold n number of <asp:checkbox> controls.
The form is getting populated from a database and the number of items can
vary. When I post back to the server how do I find out which checkbox that
are checked?


Kind regards

Tony


1 Answer

Ken Cox [MS MVP]

1/15/2003 11:40:00 PM

0

Hi Tony,

You can just loop through all of the controls inside the Form and test for the
checkboxes. When you find one, cast the control to a checkbox and spit out the
name and value.

Code below.

Does this help?

Ken
MVP [ASP.NET]

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim cntrlTest As Control
Dim chkTest As CheckBox
For Each cntrlTest In Page.Controls(1).Controls
If TypeOf cntrlTest Is CheckBox Then
chkTest = CType(cntrlTest, CheckBox)
Response.Write(chkTest.ID & "=" & chkTest.Checked.ToString & "<br>")
End If
Next
End Sub

"Tony Fabian" <tony@fabian.dk> wrote in message
news:OZINB#NvCHA.2596@TK2MSFTNGP12...
Hi



I am creating an order form which hold n number of <asp:checkbox> controls.
The form is getting populated from a database and the number of items can
vary. When I post back to the server how do I find out which checkbox that
are checked?


Kind regards

Tony