在GridView控件:DataGrid中是否有DataBound?
proctected sub gridview.DataBound(Byval sender as object, byval e assystemEventArgs) handles gridview.databound
{
}
如何使用數據綁定DataGrid中?
在GridView控件:DataGrid中是否有DataBound?
proctected sub gridview.DataBound(Byval sender as object, byval e assystemEventArgs) handles gridview.databound
{
}
如何使用數據綁定DataGrid中?
您可以根據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
VB.NET ,,,,,,,,,,,,,,,,, – Zeeju
好,但有在VB.NET中沒有大括號來定義像方法一樣的範圍。您也在使用GridView而不是舊的DataGrid。在目前的狀態下,這完全沒有問題。我建議看看MSDN第一:http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound.aspx#Y535 –
proctected子gridview.DataBound(BYVAL發件人爲對象,byval e爲systemEventArgs)處理gridview.databound End sub如何在datagrid中使用數據綁定? – Zeeju