Click here to Skip to main content
15,912,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here is my code:

XML
<asp:DataList ID="DataList1" runat="server" DataKeyField="iPKImage" DataSourceID="SqlDataSource2"
               RepeatLayout="Flow" RepeatDirection="Horizontal">
               <ItemTemplate>
                   <div class="thumb">
                       <a href='<%# "library_image.aspx?imageid=" & Eval("iPKImage") %>'>
                           <asp:Image ID="imgThumb" ImageUrl='<%# "showthumbnail.aspx?img=" & Eval("iPKImage") %>'
                               CssClass="thumbImage" runat="server" />
                       </a>
                       <asp:HyperLink ID="hlTitle" CssClass="thumbTitle" runat="server" Text='<%#Eval("Image")%>'></asp:HyperLink>
                       <div class="thumbOptions">
                           <table>
                               <tr>
                                   <td>
                                       <a href='<%# "library_image.aspx?imageid=" & Eval("iPKImage") %>'>
                                           <img src="skins/common/icons/ico_img_view.gif" alt="View image details" /></a>
                                   </td>
                                   <td>
                                       <asp:ImageButton ID="btnRequest" ImageUrl="~/skins/common/icons/ico_img_request.gif"
                                           runat="server" CommandName="AddToCart" ToolTip="Add to my image request list" />
                                   </td>
                                   <td>
                                       <asp:ImageButton ID="btnDisseminate" ImageUrl="~/skins/common/icons/ico_img_disseminate.gif"
                                           runat="server" CommandName="AddToCart" ToolTip="Add to my image dissemination list" />
                                   </td>
                                   <td>
                                       <asp:ImageButton ID="btnEdit" ImageUrl="~/skins/common/icons/ico_img_edit.gif" runat="server"
                                           CommandName="EditImage" ToolTip="Edit image" Visible="false" />
                                   </td>
                                   <td>
                                       <asp:ImageButton ID="btnDelete" ImageUrl="~/skins/common/icons/ico_del.gif" runat="server"
                                           CommandName="Delete" ToolTip="Delete image" Visible="false" />
                                   </td>
                                   <td>
                                       <asp:CheckBox  ID="cbDownload" runat="server" />
                                       <asp:HiddenField ID="hdnImageID" Value='<%# Eval("iPKImage") %>' runat="server" />
                                   </td>
                               </tr>
                           </table>
                       </div>
                   </div>
               </ItemTemplate>
           </asp:DataList>


Now, how can I find if a checkbox is checked, and if it is, select the value in the Hidden Field next to it? Thanks in advance!
Posted
Comments
Dave Kreskowiak 29-Jun-11 11:12am    
If you're dealing with an ASP.NET app, tag your questions ASP.NET as well. Most questions on ASP.NET functionality have nothing to do with the language your writing the code in.

Solved myself...sorry!

VB
Dim IDList As New List(Of Int32)
        For Each dl As DataListItem In DataList1.Items
            If (CType(dl.FindControl("cbDownload"), CheckBox).Checked) Then
                IDList.Add(Int32.Parse(CType(dl.FindControl("hdnImageID"), HiddenField).Value))
            End If
        Next
 
Share this answer
 
hi,
plz try below..it may be helpfull

Dim Dl As String = "Datalist Items Checked:<br />"
For Each dli As DataListItem In DataList1.Items
Dim chk As CheckBox = DirectCast(dli.FindControl("CategoryID"), CheckBox)
If chk.Checked Then
Dl += (chk.Text + "<br />")
End If
Next
DlLiteral.Text = Dl


refer this[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900