Getting Value out of a data repeater checkbox

J

jim.long

I can't seem to get the checked value from the checkboxes! Is there
something wrong with the code? It loops through the repeater item
collection correctly.
HTML:
<asp:repeater id="rPrinterJobs" runat="server">
<ItemTemplate>
<tr>
<td><asp:CheckBox ID="chkboxSelection" Checked=true Runat="server"
Enabled="true"></asp:CheckBox>
<asp:Label ID="hdnStoreID" Visible="false" Text='<%#
DataBinder.Eval(Container.DataItem, "UColumn0") %>'
Runat=server></asp:Label>
</td>
</tr>
</ItemTemplate>
</asp:repeater>

Code Behind:
Dim DataItem As RepeaterItem
Dim chkSelected As System.Web.UI.WebControls.CheckBox
Dim strJobID As String

Dim rc As RepeaterItemCollection = rPrinterJobs.Items
Dim MyCheckBox As CheckBox

For Each Item As RepeaterItem In rc
MyCheckBox = CType(Item.FindControl("chkboxSelection"),
CheckBox)
If MyCheckBox.Checked = True Then
strJobID = CType(Item.FindControl("hdnStoreID"),
Label).Text
If strJobID > "" Then
'Do something
End If
End If
Next
 
K

Karl Seguin

Looks right.

Wha'ts not working? Is MyCheckBox.Checked always false? Are you getting
past that but strJobID is empty?

Where's this code? In a button event handler? Is viewstate on?

Karl
 
K

Karl Seguin

Something doesn't seem right. are you rebinding the repeater on postback or
is it wrapped in an if not page.ispostback ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top