我有一个带有编辑/更新命令按钮的网格视图。我正在使用下拉菜单来设置 gridview 数据源 (ds2) 的选择命令,如下所示。
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
If ddFilter.SelectedValue = "Title" Then ds2.SelectCommand = "SELECT * FROM [contentStore] WHERE ([Title] LIKE '%' + @Title + '%') order by [Title] asc"
If ddFilter.SelectedValue = "URL" Then ds2.SelectCommand = "SELECT * FROM [contentStore] WHERE ([URL] LIKE '%' + @Title + '%') order by [URL] asc"
If ddFilter.SelectedValue = "ID" Then ds2.SelectCommand = "SELECT * FROM [contentStore] WHERE ([ID] LIKE '%' + @Title + '%') order by [ID] asc"
GridView1.DataBind()
Catch ex As Exception
lblFilter.Text = "<h3>Filter Issue</h3>" & ex.ToString
End Try
End Sub
问题是当我使用编辑/更新组合时,记录会正确更新,但是 gridview 不会再次绑定自身。如果我再次按下按钮,gridview 会按预期重新显示更新的数据。
我的问题是如何让 Gridview 在更新后自行绑定