Check/Uncheck Checkboxes using linkbutton header template inside gridview
Hello Everyone please help me I am new to this programming language
I want to create A GRIDVIEW that will Check/Uncheck Checkboxes using linkbutton header template inside gridview..Is it posible..
Thanks here's my code
CODE BEHIND:
protected void lnkInitiator_Click(object sender, EventArgs e)
{
bool chkboxIsChecked = false;
for (int i = 0; i < gridRevAppMatrix.Rows.Count; i++)
{
foreach (GridViewRow row in gridRevAppMatrix.Rows)
{
string AppID = (gridRevAppMatrix.DataKeys[row.RowIndex].Values["MatrixCondition_Idx"].ToString());
chkboxIsChecked = false;
CheckBox selected = (CheckBox)gridRevAppMatrix.Rows[i].FindControl("chkInitiator");
if ((selected.Checked == true) && (selected != null))
{
chkboxIsChecked = false;
RoleSavingReg(getRole("chkInitiator"), AppID, chkboxIsChecked);
}
else
{
chkboxIsChecked = true;
RoleSavingReg(getRole("chkInitiator"), AppID, chkboxIsChecked);
}
}
}
}
CLIENT SIDE:
<asp:TemplateField>
<HeaderStyle BackColor="#0070C0" CssClass="TimeAssigned" ForeColor="white" Font-Italic="false" Font-Bold="true" HorizontalAlign="Center" Width="50px"/>
<HeaderTemplate>
<asp:LinkButton ID="lnkInitiator" runat="server" CssClass="LinkHeader" OnClick="lnkInitiator_Click">Initiator</asp:LinkButton>
</HeaderTemplate>
<ItemTemplate>
<center>
<asp:CheckBox runat="server" id="chkInitiator" OnDataBinding="chkInitiator_DataBinding" OnCheckedChanged="chkInitiator_CheckedChanged" AutoPostBack="true" /></center>
</ItemTemplate>
</asp:TemplateField>
I really appreciate your big help on this thanks