|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Getting Value out of a data repeater checkboxsomething 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 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 Show quoteHide quote news:1134670998.704467.140760@g44g2000cwa.googlegroups.com... >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 > MyCheckBox.Checked is always false. Yes it is in a button event handler.
Something doesn't seem right. are you rebinding the repeater on postback or
is it wrapped in an if not page.ispostback ? Show quoteHide quote news:1134673764.510774.250970@f14g2000cwb.googlegroups.com... > MyCheckBox.Checked is always false. Yes it is in a button event handler. >
Other interesting topics
Anyone tried the design templates from MSDN?
.Net 2, asp:Literal outside a server form = unrecognized tag prefix Merge two tables of a Dataset in only one Datatable Auto Mode FTP in .NET 1.1 Gripe: usability problems with directory listing in .Net 2 download location... Virtual images for the team system Receive a post of XML Document RAM based cookies NO DLL in bin folder after building dataset question - to preserve DB resources |
|||||||||||||||||||||||