Никогда не использовать (AppendDataBoundItems = "true")!
<asp:DropDownList ID="drpdwnmodel" DataSourceID="Model_Grid" DataTextField="INI" DataValueField="INI" OnSelectedIndexChanged="drprep_SelectedIndexChanged" OnDataBound="DataBoundbyTest_click" AutoPostBack="true" runat="server">
<asp:ListItem Value="All" Text="All"></asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="Model_Grid" runat="server"
ConnectionString="<%$ ConnectionStrings:Testconnectionstring%>"
SelectCommand="SELECT DISTINCT INI FROM TestTable where [Column] LIKE '%' + @valuename+ '%' ORDER BY INI ASC">
<SelectParameters>
<asp:ControlParameter ControlID="drpdwnmodel" Name="valuename"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
protected void DataBoundbyTest_click(object sender, EventArgs e)
{
drpdwnmodel.Items.Add("All");
drpdwnmodel.Items.Insert(0, new ListItem("- Select -", "0"));
}
protected void drprep_SelectedIndexChanged(object sender, EventArgs e)
{
if (drpdwnmodel.SelectedValue.Equals("0"))
{
GridView1.DataSourceID = "Test_Grid";
}
else {
if (drpdwnmodel.SelectedValue.Equals("All"))
{
GridView1.DataSourceID = "Test_Grid";
}
else
{
GridView1.DataSourceID = "SqlDataSource1";
}
}
}