2013-04-27 94 views
0

無法獲取gridview單元格的值。我綁定的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"; 
     } 

    } 
+0

有什麼錯誤? – zey 2013-04-27 07:35:02

+0

沒有任何錯誤。數據綁定完美,我只想獲取單元格中的值.. – 2013-04-27 08:14:18

+0

,我可以更改數據但無法訪問它 – 2013-04-27 08:19:31

回答

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"; 
         } 
      } 
    } 
    } 
+0

明白了..謝謝 – 2013-04-27 09:32:36

+0

使用我的答案或不? – zey 2013-04-27 10:34:02

+0

沒有zey這是另一個問題,謝謝你的幫助 – 2013-04-29 11:51:14

相關問題