DataGrid中有DataBound吗?

时间:2012-09-11 08:31:02

标签: asp.net vb.net datagrid databound-controls

GridView中的

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

}

如何在DATAGRID中使用DataBound?

2 个答案:

答案 0 :(得分: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;

   }

答案 1 :(得分: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