Click here to Skip to main content
15,890,609 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i use DropDown List With OptGroup Support,

which work fine, but my problem is when dropdown list is selectd,
it lost OptionGroup fuctionlity, So what can i do for this,...

I use This Link:

http://www.codeproject.com/Tips/638625/DropDown-List-With-OptGroup-Support
Posted
Updated 11-Nov-13 19:31pm
v2
Comments
Can you show the code which binds the DropDownList and the Page Load?
Arun kumar Gauttam 12-Nov-13 1:41am    
private void MakeDropDown()
{

ListItem item1 = new ListItem("Only 1 Star", "1");
item1.Attributes["OptionGroup"] = "By Star Ratting";
ListItem item2 = new ListItem("Only 2 Star", "2");
item2.Attributes["OptionGroup"] = "By Star Ratting";
ListItem item3 = new ListItem("Only 3 Star", "3");
item3.Attributes["OptionGroup"] = "By Star Ratting";
ListItem item4 = new ListItem("Only 4 Star", "4");
item4.Attributes["OptionGroup"] = "By Star Ratting";
ListItem item5 = new ListItem("Only 5 Star", "5");
item5.Attributes["OptionGroup"] = "By Star Ratting";
ListItem item6 = new ListItem("View All", "6");
item6.Attributes["OptionGroup"] = "By Star Ratting";


ListItem item7 = new ListItem("Reviews With material Facts", "7");
item7.Attributes["OptionGroup"] = "By Material Fact";
ListItem item8 = new ListItem("Reviews Without material Facts", "8");
item8.Attributes["OptionGroup"] = "By Material Fact";
ListItem item9 = new ListItem("Only Text Reviews", "9");
item9.Attributes["OptionGroup"] = "By Review Type";
ListItem item10 = new ListItem("Only Video Reviews", "10");
item10.Attributes["OptionGroup"] = "By Review Type";


DdlSortingViaStar.Items.Add(item1);
DdlSortingViaStar.Items.Add(item2);
DdlSortingViaStar.Items.Add(item3);
DdlSortingViaStar.Items.Add(item4);
DdlSortingViaStar.Items.Add(item5);
DdlSortingViaStar.Items.Add(item6);
DdlSortingViaStar.Items.Add(item7);
DdlSortingViaStar.Items.Add(item8);
DdlSortingViaStar.Items.Add(item9);
DdlSortingViaStar.Items.Add(item10);



}



on page Load:
if (!IsPostBack)
{

MakeDropDown();
}

I also Try This
MakeDropDown();

Direct On Page Load
Have you called the function inside the SelectedIndexChanged event? If not, try once.
Arun kumar Gauttam 12-Nov-13 2:28am    
if i bind fuction on SelectedIndexChanged event,then selected data will be lost and dropdown list data is Just Doubble, So for this i try this:

string yy = DdlSortingViaStar.SelectedValue;
DdlSortingViaStar.Items.Clear();
MakeDropDown();
DdlSortingViaStar.Text = yy;

And it work Fine,
Thank you very much,For suggestion.....
Ya, I was just going to give you exactly this solution. Anyway, good job.
I have added one answer, please accept that. :)

1 solution

Clearing the DropDownList, then binding it again inside SelectedIndexChanged event solved the issue.
C#
string yy = DdlSortingViaStar.SelectedValue;
DdlSortingViaStar.Items.Clear(); 
MakeDropDown();
DdlSortingViaStar.Text = yy;
 
Share this answer
 
Comments
Arun kumar Gauttam 12-Nov-13 3:34am    
thanks.......
Most welcome. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900