I have CheckedChanged event handler that hides a row from a gridview when the checkbox is checked. Now when I uncheck the checkbox, nothing happens. I actually want the row that gets hidden to be visible when the checkbox is unchecked. So I want the opposite to happen when I uncheck the checkbox. Currently the event handler does hide the row but I want the row to re-appear when I uncheck the checkbox
The checkbox:
<div class="row mt-4 mb-2" style="width: 50%; margin: auto;">
<div class="col-md-12">
<div class="check-label-Prof-Clients" >
<asp:CheckBox ID="chkProfClients" class="check-trading" runat="server" Enabled="true" AutoPostBack="true"
ViewStateMode="Enabled" EnableViewState="true" Checked="false" OnCheckedChanged="chkProfClients_CheckedChanged"/>
<label class="form-check-label" style="font-size: 14px; font-weight: 400;" for="chkProfClients">
Only Show Profitable Clients
</label>
</div>
</div>
</div>
The checkbox CheckedChanged event handler:
protected void chkProfClients_CheckedChanged(object sender, EventArgs e)
{
for (int i = 0; i <= gridProfitMargin.Rows.Count - 1; i++)
{
var profitValue = Convert.ToDouble(gridProfitMargin.Rows[i].Cells[13].Text);
if (profitValue <= 0)
{
gridProfitMargin.Rows[i].Visible = false;
}
else
{
gridProfitMargin.Rows[i].Visible = true;
}
}
}
I have "Autopostback = true". But still, nothing happens when I uncheck the checkbox