在网格视图中:
proctected sub gridview.DataBound(Byval sender as object, byval e assystemEventArgs) handles gridview.databound
{
}
如何在 DATAGRID 中使用 DataBound?
在网格视图中:
proctected sub gridview.DataBound(Byval sender as object, byval e assystemEventArgs) handles gridview.databound
{
}
如何在 DATAGRID 中使用 DataBound?
您可以尝试使用此代码基于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;
}
老实说,您的问题目前没有多大意义。但是如果你想处理 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