I'm using a gridview and I need to get the contents of the line to which the checkbox is checked==true
. I can get the status of checkbox
, but the text property of the cell is coming in white.
Follow the code below:
protected void btnEnviar_Click(object sender, EventArgs e)
{
int i = 0;
while (i < gvwNot.Rows.Count)
{
GridViewRow row = gvwNot.Rows[i];
CheckBox isChecked = (CheckBox)row.FindControl("chkSelect");
if (isChecked.Checked == true)
{
string str = gvwNot.Rows[i].Cells[1].Text;
//Fazer um update na PRT alterando os campos DATA RETORNO e Data Limite
//PRT_DT_LM_PGT
//nrc_dt_sta
}
i++;
}
//Impressão de intimações realizada com sucesso.
}
ASP.NET
<asp:GridView ID="gvwNot" runat="server" AutoGenerateColumns="False" DataKeyNames="COD" AllowPaging="True" AllowSorting="true" PageSize="10" CssClass="table table-bordered table-hover table-striped" >
<Columns>
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" />
</ItemTemplate>
<HeaderTemplate>
<input id="chkAll" onclick="javascript: SelecionaTodosChecks(this);" runat="server" type="checkbox" />
</HeaderTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Cod." >
<ItemTemplate><%#Eval("COD") %> </ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerSettings Mode="NextPrevious" NextPageText="Próximo" PreviousPageText="Anterior" />
</asp:GridView>