如何在下拉列表的onSelectedIndexChanged()中刷新GridView?

时间:2016-06-24 03:05:40

标签: asp.net vb.net gridview

如何刷新下拉列表GridView中的onSelectIndexChange? 我希望在每次索引更改时刷新或清除网格 当ddlist.selectvalue=0然后弹出一个说Please select valid option,然后网格隐藏。

我正在使用此代码:

 Protected Sub ddllist_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddllist.SelectedIndexChanged
        If ddllist.SelectedValue = 1 Then

            tdtype.InnerHtml = "Leas ID"
            btnSave.Enabled = True
            trtype.Visible = True

        ElseIf (ddllist.SelectedValue = 0) Then
            btnSave.Enabled = False
            trtype.Visible = False
            ' Gridconten.DataSource = ""
            'Gridconten.DataBind()
            'Page_Load(sender, e)
            Gridconten.DataSource = Nothing
            Gridconten.DataBind()

        Else
            btnSave.Enabled = True
            tdtype.InnerHtml = "Vendor ID"
            trtype.Visible = True
        End If
    End Sub

1 个答案:

答案 0 :(得分:0)

  

好吧,经过一番尝试,我得到了它,我正在使用它!   基本上我是绑定它没有数据和隐藏索引上的网格   变化

 Protected Sub ddllist_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddllist.SelectedIndexChanged
        If ddllist.SelectedValue = 1 Then
            Label2.Text = ""
            tdtype.InnerHtml = "Leas ID"
            btnSave.Enabled = True
            trtype.Visible = True
            Gridconten.DataSource = Nothing
            Gridconten.DataBind()
            Gridconten.Visible = False
            Gridconten.Columns(0).HeaderText = "Lease ID"

        ElseIf (ddllist.SelectedValue = 0) Then
            btnSave.Enabled = False
            trtype.Visible = False
            Label2.Text = ""
            ' Gridconten.DataSource = ""
            'Gridconten.DataBind()
            'Page_Load(sender, e)
            Gridconten.DataSource = Nothing
            Gridconten.DataBind()

            Gridconten.Visible = False

        Else
            Label2.Text = ""
            btnSave.Enabled = True
            tdtype.InnerHtml = "Vendor ID"
            trtype.Visible = True
            Gridconten.DataSource = Nothing  
            Gridconten.DataBind()            
            Gridconten.Visible = False
            Gridconten.Columns(0).HeaderText = "Vendor ID"
        End If
    End Sub