Sign in to follow this  
aKa Davi

[web] Grid View Row Loop Testing Checkbox Checked

Recommended Posts

aKa Davi    122
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?

Share this post


Link to post
Share on other sites
aKa Davi    122
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 =]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this