[web] Grid View Row Loop Testing Checkbox Checked

Started by
0 comments, last by aKa Davi 17 years, 5 months ago
Hi, In ASP.NET im using a GridView to display data from a oracle stored procedure. I have added a column to teh start of the gridview, and added a checkbox. The aim is that the user will check all the enquiries that they wish to include within the XML file. here is my code (im jst using msgbox's to debug whether or not the form is working properly)

Dim dr As GridViewRow

        For Each dr In UnBatchedEnquiries.Rows
            Dim RowCheckBox As System.Web.UI.WebControls.CheckBox = dr.FindControl("RowCheckBox")
            If RowCheckBox.Checked = True Then
                MsgBox("Is Checked")
            End If
        Next

---This is my GridView--- <asp:GridView ID="UnBatchedEnquiries" runat="server" Width="100%"> <Columns> <asp:TemplateField HeaderText="IncludeEnquiry" > <HeaderTemplate>Include?</HeaderTemplate> <ItemTemplate> <asp:CheckBox id="RowCheckBox" runat="server"></asp:CheckBox> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> But for some reason this code isnt working. Does anyone know why?
Advertisement
Hey i found why i was having the problem i was, it was to do with the form postback
i found a forumnpost that was having the exact same problem and this was the solution

in your Page_Load function



If Not (Page.IsPostBack) Then

'Your Bind Data Function

GridViewBind()

End If



Thanks for all your help =]

This topic is closed to new replies.

Advertisement