Jump to content

datagrid and checkboxs


defiant1970
 Share

Recommended Posts

I have a web form using a data grid with checkboxs to select different data enterys. I have used this same peice of code on another page and it works great but when I use it on the newer page the check all boxs doesn't auto post back right (none of the boxs are checked) and the selected data entery is not changed. Maybe some out there has ran into this and can give me some advice.Sub UpdatePaid(ByVal o As Object, ByVal e As EventArgs) Dim i As Integer For i = 0 To MyList.Items.Count - 1 Dim Add As CheckBox = CType(MyList.Items(i).FindControl("Add"), CheckBox) If Add.Checked = True Then Dim ListingID As Label = CType(MyList.Items(i).FindControl("callID"), Label) Try If Add.Checked = True Then UpdatePayment(CInt(ListingID.Text)) End If Catch MyError.Text = "There has been a problem with one or more of your inputs." End Try End If Next End Sub Protected Sub chkCheckAll_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Dim chkCheckAll As CheckBox = CType(sender, CheckBox) For RowCount As Integer = 0 To MyList.Items.Count - 1 CType(MyList.Items(RowCount).Cells(0).FindControl("Add"), CheckBox).Checked = chkCheckAll.Checked Next End Sub<asp:DataGrid id="MyList" BorderColor="black" GridLines="Vertical" cellpadding="4" cellspacing="0" ShowFooter="true" AutoGenerateColumns="false" runat="server"> <FooterStyle font-size="Smaller" BackColor="#A3EB85" forecolor="Black"></FooterStyle> <HeaderStyle font-size="Smaller" BackColor="#A3EB85" forecolor="Black"></HeaderStyle> <ItemStyle font-size="Smaller" BackColor="White" forecolor="Black"></ItemStyle> <Columns> <asp:TemplateColumn headertext="ID"> <ItemTemplate> <asp:Label id="callID" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "callID") %>' /> </ItemTemplate> </asp:TemplateColumn> <asp:BoundColumn HeaderText="First Name" DataField="callerFName" /> <asp:BoundColumn HeaderText="Last Name" DataField="callerLName" /> <asp:BoundColumn HeaderText="Company" DataField="callerCompany" /> <asp:HyperLinkColumn HeaderText="Invoice" text="Invoice" DataNavigateUrlField="callID" DataNavigateUrlFormatString="Invoice_Print.aspx?callID={0}" /> <asp:TemplateColumn HeaderText="Add"> <HeaderTemplate> <asp:CheckBox AutoPostBack = "true" ID = "chkCheckAll" runat = "server" OnCheckedChanged = "chkCheckAll_CheckedChanged"/> </HeaderTemplate> <ItemTemplate> <center> <asp:CheckBox id="Add" runat="server" /> </center> </ItemTemplate> </asp:TemplateColumn> </Columns> </asp:DataGrid>

Link to comment
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
 Share

×
×
  • Create New...