Hi there, I need your help.
Here is my problem.
I have this DropDownList populate with this query in dbms SQL Server 2008:
sql2 = "SELECT * FROM dbo_40 " +
" ORDER BY " +
" Sort;";
dadapter = new SqlDataAdapter(sql2, ConnSqlServer);
dset = new DataSet();
dadapter.Fill(dset);
DropDownList3.DataSource = dset.Tables[0];
DropDownList3.DataTextField = "MAT";
DropDownList3.DataValueField = "Sort";
DropDownList3.DataBind();
In this DDL I need add the ALL value and tried this code:
<asp:DropDownList ID="DropDownList3" runat="server" AppendDataBoundItems="True" AutoPostBack="True"
Font-Size="10pt" OnSelectedIndexChanged="DropDownList3_SelectedIndexChanged">
<asp:ListItem Value="%">---</asp:ListItem>
<asp:ListItem Value="5">ALL</asp:ListItem>
</asp:DropDownList>
public void GridViewBind()
{
sql1 = "SELECT TOP 1000 * FROM dbo_40;";
if (DropDownList3.SelectedIndex == 5)
{
sql1 = "SELECT * FROM dbo_40 WHERE sID = 5;";
Response.Write(DropDownList3.SelectedIndex);
}
}
protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewBind();
}
But in the code-behind the value DropDownList3.SelectedIndex for ALL it's null or empty.
Can you help me?
Thanks in advance.