Is there DataBound in DataGrid?

2.4k views Asked by At

in GridView:

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

}

how to use DataBound in DATAGRID??

2

There are 2 answers

0
Aghilas Yakoub On

You can try with this code based on 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;

   }
3
Tim Schmelter On

To be honest, your question doesn't make much sense currently. But if you want to handle the GridView's DataBound event (as opposed to the RowDataBound event):

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