我们有一个ASP.Net / VB.Net代码隐藏的Web表单。在这个表单上是GridView和DetailsView。
当详细信息视图发生更改时,我们希望更改能够反映在GridView中。
此代码用于填充GridView:
Private Sub Teachers_Init(sender As Object, e As EventArgs) Handles Me.Init
' Load the data from the database into the GridView.
'---------------------------------------------------
GridViewSummary.DataSource = theTableAdapter.GetDataAllTeachers
GridViewSummary.DataBind()
End Sub
在DetailsView中更改细节后,此编码用于反映GridView中的更改:
Private Sub DetailsView_ItemUpdated(sender As Object, e As DetailsViewUpdatedEventArgs) Handles DetailsView.ItemUpdated
' Refresh the data so current values are displayed.
'--------------------------------------------------
GridViewSummary.DataSource = theTableAdapter.GetDataAllTeachers
GridViewSummary.DataBind()
End Sub
有没有办法不需要使用:
GridViewSummary.DataSource = theTableAdapter.GetDataAllTeachers
在上面的编码?我知道它只是一行代码,但如果不需要它就想消除它。