1

在网格视图中:

proctected sub gridview.DataBound(Byval sender as object, byval e assystemEventArgs) handles gridview.databound
{

}

如何在 DATAGRID 中使用 DataBound?

4

2 回答 2

0

您可以尝试使用此代码基于OnItemDataBound

   <asp:DataGrid 
   id="ItemsGrid" 
   runat="server"
   OnItemDataBound="Item_Bound"
           .../>

   //Code behind
   void Item_Bound(Object sender, DataGridItemEventArgs e) 
   {

      Label1.Text = Label1.Text + " " + e.Item.ItemIndex;

   }
于 2012-09-11T08:46:47.817 回答
0

老实说,您的问题目前没有多大意义。但是如果你想处理 GridView 的DataBound事件(而不是RowDataBound事件):

Protected Sub Gridview1_DataBound(sender As Object, e As System.EventArgs) Handles Gridview1.DataBound
    Dim grid = DirectCast(sender, GridView)
    Dim dataSource As Object = grid.DataSource
    For Each row As GridViewRow In grid.Rows
        ' do something, looping all rows in the grid with RowType=DataRow '
    Next row
End Sub
于 2012-09-11T08:48:44.060 回答