In a GridView I'm trying to get the data for a row where checkbox == true
.
I can get the value of the checkbox, but I can not get the other values for the line.
while (i < gvwNot.Rows.Count)
{
GridViewRow row = gvwNot.Rows[i];
CheckBox isChecked = (CheckBox)row.FindControl("chkSelect");
//TextBox id = (TextBox)row.FindControl("ID");
//TextBox nome = (TextBox)row.FindControl("NOME");
if (isChecked.Checked == true)
{
string id = gvwNot.Rows[i].Cells[1].Text;
string nome = gvwNot.Rows[i].Cells[3].Text;
qry = sb.ToString();
qtd = qtd + 1;
}
i++;
}
<asp:GridView ID="gvwNot" runat="server"
AutoGenerateColumns="False"
DataKeyNames="Id"
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="Id">
<ItemTemplate><%#Eval("ID") %> </ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Protocolo">
<ItemTemplate><%#Eval("NOME") %> </ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerSettings Mode="NextPrevious" NextPageText="Próximo" PreviousPageText="Anterior" />
</asp:GridView>