开发者

change filter expression with abutton click

开发者 https://www.devze.com 2023-03-08 04:23 出处:网络
I want to change my filter expression if a certain item is selected in a dropdownlist and the person clicks the button

I want to change my filter expression if a certain item is selected in a dropdownlist and the person clicks the button

 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        If DropDownList1.SelectedItem.Text = "JOANNEP" Or DropDownList1.SelectedItem.Text = "ANAB" Then
            SqlDataSource1.FilterExpression = "byyyy <> 2009"
        Else
            SqlDataSource开发者_如何学运维1.FilterExpression = Nothing
        End If
        UpdatePanel1.Update()
    End Sub

i tryed that however my gridview still shows byyyy years that include 2009


Try calling gridView1.DataBind() after the If-Else-EndIf block;

EDIT: Just guessing but try this

SqlDataSource1.FilterExpression = "byyyy <> {0}"
SqlDataSource1.FilterParameters.Clear();
SqlDataSource1.FilterParameters.Add("byyyy", "2009")
0

精彩评论

暂无评论...
验证码 换一张
取 消