无法访问网格视图单元格值
本文关键字:单元格 视图 网格 访问 | 更新日期: 2023-09-27 18:11:11
无法获取gridview单元格的值。我正在动态绑定gridview
<asp:Panel ID="PnlGrid" runat="server" ScrollBars="Both" CssClass="gridLayout">
<asp:GridView ID="grdExamReportBatchWise" runat="server" CssClass="gridReport" AutoGenerateColumns="false">
<Columns>
</Columns>
<EmptyDataTemplate>
Records not present !
</EmptyDataTemplate>
</asp:GridView>
</asp:Panel>
for (int i = 0; i < grdExamReportBatchWise.Columns.Count - 1; i++)
{
if (grdExamReportBatchWise.Rows[0].Cells[i].Text == "Paper")
{
string ne = "abc";
}
}
试试看,
protected void grdExamReportBatchWise_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.DataItem != null)
{
for (int i = 0; i < grdExamReportBatchWise.Columns.Count - 1; i++)
{
if (e.Row.Cells[i].Text == "Paper")
{
string ne = "abc";
}
}
}
}