2011-01-07 132 views

回答

4

也許下面的方法會有所幫助。

標記:

<asp:GridView id="testGrid" OnRowDataBound="testGrid_RowDataBound" ... runat="server"> 
    ...... 
</asp:GridView> 

代碼隱藏:

protected void testGrid_RowDataBound(object sender, GridViewRowEventArgs e) 
{ 
    string val = string.Empty; 

    if (e.Row.RowType == DataControlRowType.DataRow) 
    { 
     foreach(TableCell cell in e.Row.Cells) 
      val = cell.Text; 
    } 
} 

- 帕維