i find the problem. i use the sqldatasources. change with sqldataadapter problem is fixed. thank you for support.
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub form1_Load(sender As Object, e As EventArgs) Handles form1.Load
If Not IsPostBack Then
ViewState("Filter") = "ALL"
Me.BindGrid()
End If
End Sub
Private Sub BindGrid()
If ViewState("Filter") = "ALL" Then
sqldata.SelectCommand = "SELECT * FROM [tbl_ssf]"
Else
sqldata.SelectCommand = "SELECT * FROM [tbl_ssf] where ilce='" & ViewState("Filter") & "'"
End If
sqldata.DataBind()
'GridView1.DataSource = sqldata
GridView1.DataBind()
Dim ddlCountry As DropDownList = DirectCast(GridView1.HeaderRow.FindControl("ddlCountry"), DropDownList)
Me.BindCountryList(ddlCountry)
End Sub
Private Sub BindCountryList(ByVal ddlCountry As DropDownList)
ddlCountry.Items.FindByValue(ViewState("Filter").ToString()).Selected = True
End Sub
Protected Sub CountryChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim ddlCountry As DropDownList = DirectCast(sender, DropDownList)
ViewState("Filter") = ddlCountry.SelectedValue
Me.BindGrid()
End Sub
Protected Sub OnPaging(sender As Object, e As GridViewPageEventArgs)
GridView1.PageIndex = e.NewPageIndex
Me.BindGrid()
End Sub
End Class
************aspx code****
<form id="form2" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" AllowPaging="True"
Font-Names="Arial" Font-Size="11pt" AlternatingRowStyle-BackColor="#C2D69B" HeaderStyle-BackColor="green"
OnPageIndexChanging="OnPaging" DataSourceID="sqldata">
<AlternatingRowStyle BackColor="#C2D69B"></AlternatingRowStyle>
<Columns>
<asp:BoundField DataField="il" HeaderText="il" />
<asp:BoundField DataField="ilce" HeaderText="ilce" />
<asp:TemplateField>
<HeaderTemplate>
ilce
<asp:DropDownList ID="ddlCountry" runat="server" OnSelectedIndexChanged="CountryChanged"
AutoPostBack="True" AppendDataBoundItems="True" DataSourceID="sqldatacombobox"
DataTextField="ilce" DataValueField="ilce">
<asp:ListItem Text="ALL" Value="ALL"></asp:ListItem>
</asp:DropDownList>
</HeaderTemplate>
<ItemTemplate>
<%# Eval("ilce")%>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle BackColor="Green"></HeaderStyle>
</asp:GridView>
<asp:SqlDataSource ID="sqldata" runat="server" ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>"
SelectCommand="SELECT * FROM [tbl_ssf]"></asp:SqlDataSource>
<asp:SqlDataSource ID="sqldatacombobox" runat="server" ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>"
SelectCommand="SELECT DISTINCT [ilce] FROM [tbl_ssf]"></asp:SqlDataSource>
</div>
</form>