clear drop down on radiobutton selected index changed
I have a devexpress calendar. The calendar has built in functions for grouping calendar by resource(which is location in my case). SO, I wrote my logic for making the calendar group by class name and provider too. The two work good individually. But when i was trying to place a radiobutton list so that user can select the way he want to group calendar,i had a problem.
This my radio button list and code behind event handler for it:
protected开发者_如何学编程 void filtertype_changed(object sender, EventArgs e)
{
if (filtertype.SelectedValue == "None")
{
// ASPxScheduler1.AppointmentDataSource = LoadAppointments();
classList.Visible = false;
providerslist.Visible = false;
classList.SelectedIndex = 0;
classList.SelectedIndex = 0;
//classList.SelectedValue = "0";
//providerslist.SelectedValue = "0";
ASPxScheduler1.GroupType = DevExpress.XtraScheduler.SchedulerGroupType.None;
}
else if (filtertype.SelectedValue == "Location")
{
// ASPxScheduler1.Dispose();
classList.Visible = false;
providerslist.Visible = false;
ASPxScheduler1.GroupType =
DevExpress.XtraScheduler.SchedulerGroupType.Resource;
}
else
{
ASPxScheduler1.GroupType = DevExpress.XtraScheduler.SchedulerGroupType.None;
classList.Visible = true;
providerslist.Visible = true;
}
}
This is my mark up for radio button
<asp:RadioButtonList ID="filtertype" runat="server"
OnSelectedIndexChanged="filtertype_changed" AutoPostBack="true" >
<asp:ListItem selected="true" Text="None" Value="None"></asp:ListItem>
<asp:ListItem Text="Location" Value="Location"></asp:ListItem>
<asp:ListItem>class Name and Provider</asp:ListItem>
</asp:RadioButtonList>
<asp:DropDownList ID="classList" runat="server" AutoPostBack="true"
Visible="false" ></asp:DropDownList>
<asp:DropDownList ID="providerslist" runat="server" AutoPostBack="true" Visible="false"
></asp:DropDownList>
classList and Provider List are the dropdownlists. So, what happens is when I change from Class and Provider radio button to location or none radio button, the calendar wont get refreshed and stores the values as per the dropdownlist and groups the calendar by location for those values only. So, once I change from classname and providers, I need to clear the dropdownlist values to 0(no item just white space). Can u just let me know how i can do this?
Throwing out the obvious here, but what about?:
DropDownList1.ClearSelection();
DropDownList1.Items.Clear();
精彩评论