0

无法获取 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";
        }

    }
4

1 回答 1

0

试试看 ,

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";
                        } 
          }
     }
  }
于 2013-04-27T08:36:36.993 回答