D
Dan
Hi,
in this gridview, there is in each row a checkbox linked to a field in the
database. Some are checked, other not. I want to know how many are (e.g.)
unchecked when the gridview is loaded.
This is my attempt (vb.net), but it doesn't work.
Thanks for help.
Dan.
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridView1.RowDataBound
dim x as integer = 0
If e.Row.RowType = DataControlRowType.DataRow Then
if e.Row.Cells(2).Text = "false" then x=x+1
response.write("number of unchecked checkbox:" & x)
end if
end Sub
asp:GridView ID="GridView1" runat="server" />
<Columns>
<asp:CommandField ShowSelectButton="true" />
<asp:BoundField DataField="id" HeaderText="id" ReadOnly="True" />
<asp:TemplateField HeaderText="selected" >
<ItemTemplate>
<asp:CheckBox ID="chb" runat="server" Checked='<%# Bind("selct") %>' >
</asp:CheckBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
in this gridview, there is in each row a checkbox linked to a field in the
database. Some are checked, other not. I want to know how many are (e.g.)
unchecked when the gridview is loaded.
This is my attempt (vb.net), but it doesn't work.
Thanks for help.
Dan.
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridView1.RowDataBound
dim x as integer = 0
If e.Row.RowType = DataControlRowType.DataRow Then
if e.Row.Cells(2).Text = "false" then x=x+1
response.write("number of unchecked checkbox:" & x)
end if
end Sub
asp:GridView ID="GridView1" runat="server" />
<Columns>
<asp:CommandField ShowSelectButton="true" />
<asp:BoundField DataField="id" HeaderText="id" ReadOnly="True" />
<asp:TemplateField HeaderText="selected" >
<ItemTemplate>
<asp:CheckBox ID="chb" runat="server" Checked='<%# Bind("selct") %>' >
</asp:CheckBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>