C# page.
I have two dropdowns. They are both independant of each other. When I select from one of the dropdowns data is displayed in a gridview. When I select from another dropdown the data is displayed based on that choice.
My problem is that the choice from the other dropdown is still selected so I cant select it again unless I select another choice from the same drop down.
How would I be able to change the selection in that dropdown list back to lets say "-- Select a Driver --" or "-- Select a Route --" .
Here are my dropdowns:
<br />
<asp:Label ID="Label1" runat="server" Text="Driver:" Width="88px"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server" Width="159px" AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="employee_num" DataValueField="employee_name" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" OnDataBound="DropDownList1_DataBound">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MobileDataConnectionString %>"
SelectCommand="SELECT employee_num, [first_name] +' '+[last_name] as employee_name FROM [employee]"></asp:SqlDataSource>
<br />
<asp:Label ID="Label6" runat="server" Text="Route:" Width="88px"></asp:Label>
<asp:DropDownList ID="DropDownList2" runat="server" Width="159px" AutoPostBack="True" DataSourceID="SqlDataSource2" DataTextField="rid" DataValueField="route_id" OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged" OnDataBound="DropDownList2_DataBound">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:MobileDataConnectionString %>"
SelectCommand="SELECT route, route_id, route + ', ' + CONVERT (char(3), route_id) AS rid FROM stop WHERE (DATEDIFF(dayofyear, date, GETDATE()) < 31) GROUP BY route, route_id">
</asp:SqlDataSource>
And the events I am using with them:
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
txtEmployeeName.Text = "Name";
txtEmployeeNum.Text = "0";
//Resets the fields above so the data dosnt combine with route date.
txtRouteID.Text = DropDownList2.SelectedValue;
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
txtRouteID.Text = "0";
//Resets the field above so the data dosnt combine with the employee data.
txtEmployeeNum.Text = DropDownList1.SelectedItem.Text;
txtEmployeeName.Text = DropDownList1.SelectedValue;
}
protected void DropDownList1_DataBound(object sender, EventArgs e)
{
DropDownList1.Items.Insert(0, new ListItem("-- Select By Driver --"));
}
protected void DropDownList2_DataBound(object sender, EventArgs e)
{
DropDownList2.Items.Insert(0, new ListItem("-- Select By Route --"));
//Problems:--> not an INT = when selected will cause an error.
}
So if any one has any input on how I can acomplish this it will be greatly apreciated.