Asp.net Gridview OnRowDataBound循环遍历单元格

Asp.net Gridview OnRowDataBound循环遍历单元格,asp.net,Asp.net,我正在使用ASP.NET4。如何使用OnRowDataBound事件循环并读取行中每个单元格的值 谢谢。也许下面的方法会有所帮助 标记: <asp:GridView id="testGrid" OnRowDataBound="testGrid_RowDataBound" ... runat="server"> ...... </asp:GridView> -帕维尔 protected void testGrid_RowDataBound(object sende

我正在使用ASP.NET4。如何使用OnRowDataBound事件循环并读取行中每个单元格的值


谢谢。

也许下面的方法会有所帮助

标记:

<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;
    }
}