1

in GridView:

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

}

how to use DataBound in DATAGRID??

Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939
Zeeju
  • 99
  • 1
  • 11
  • Ok, but there are no braces in VB.NET to define a scope like a method. You are also using a GridView instead of an old DataGrid. This is no question at all in the current state. I would suggest to have a look at msdn first: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound.aspx#Y535 – Tim Schmelter Sep 11 '12 at 08:42
  • proctected sub gridview.DataBound(Byval sender as object, byval e as systemEventArgs) handles gridview.databound End sub how to use databound in datagrid? – Zeeju Sep 11 '12 at 08:44
  • are you understand my question? – Zeeju Sep 11 '12 at 08:46

2 Answers2

0

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;

   }
Aghilas Yakoub
  • 28,516
  • 5
  • 46
  • 51
0

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
Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939
  • oh okay but some task is not working in RowDataBound,, if i work with databound in gridview, it's work fine but the same task is not working in datagrid.rowdatabound – Zeeju Sep 11 '12 at 08:52
  • @ShaiRiyaz: Are you kidding, what task? And also, why do you ask for `DataBound` if you actually mean `RowDataBound`? – Tim Schmelter Sep 11 '12 at 08:53
  • Task is -- Three textbox in datagrid(A,B,C) A*B=c am getting the value (A,B) from rowdatabound in codebehind and passing those value to javascript function,,, doing operation and showing the result to C – Zeeju Sep 11 '12 at 08:59