我正在尝试将行设置为不可见的用户选择True但方法不起作用。请帮忙。
谢谢!
Protected Sub dg_RowDataBound(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dg.ItemDataBound
Dim ddl As New DropDownList
Dim lbl As New Label
Dim ddlretired As New DropDownList
Dim lblretired As New Label
If (e.Item.ItemType = ListItemType.EditItem And dg.EditItemIndex = e.Item.ItemIndex) Then
ddl = e.Item.FindControl("ddlType")
lbl = e.Item.FindControl("lbltype")
ddlretired = e.Item.FindControl("ddlEdit")
lblretired = e.Item.FindControl("lblretired")
ddl.Items.FindByText(lbl.Text).Selected = True
ddlretired.Items.FindByText(lblretired.Text).Selected = True
lbl.Visible = False
lblretired.Visible = False
End If
End Sub
答案 0 :(得分:0)
我相信在将可见性设置为false之前,您必须暂停绑定。
从下面的链接
CurrencyManager currencyManager1 = (CurrencyManager)BindingContext[MyGrid.DataSource]; currencyManager1.SuspendBinding(); MyGrid.Rows[5].Visible = false; currencyManager1.ResumeBinding();