I have a dropdownlist1 which has been manually filled. I have a code behind to fill another dropdownlist2 using dropdownlist1's selected indexchanged event.
I tried Autopostback="true" for dropdownlist1.
It loads the listitems for the first selection.
But when i change the selection, it does not post back. The list items remain the same.
Please help me... Thanks!
Please remember to click "Mark as Answer" on the post that helps you. It can be beneficial to other community members reading the thread.
GeorgeTheOne
Member
24 Points
21 Posts
How to fill values of a dropdownlist by using selected index changed event of another dropdownlis...
Jun 12, 2012 01:10 PM|LINK
I have a dropdownlist1 which has been manually filled. I have a code behind to fill another dropdownlist2 using dropdownlist1's selected indexchanged event.
I tried Autopostback="true" for dropdownlist1.
It loads the listitems for the first selection.
But when i change the selection, it does not post back. The list items remain the same.
Please help me... Thanks!
Mudasir.Khan
All-Star
15346 Points
3142 Posts
Re: How to fill values of a dropdownlist by using selected index changed event of another dropdow...
Jun 12, 2012 01:23 PM|LINK
after setting Autopostback="true" for dropdown1 we need to implement the event on selectionIndexChange inside this event bind the dropdown2
please check this
http://forums.asp.net/p/1715517/4574789.aspx/1?DropDownList+autopostback
GeorgeTheOne
Member
24 Points
21 Posts
Re: How to fill values of a dropdownlist by using selected index changed event of another dropdow...
Jun 12, 2012 01:28 PM|LINK
Hey Mudasir! Thanks for replying.... Really appreciate it...
Can you also let me know how could i clear the contents of another dropdownlist using same event?
nadellas
Participant
1218 Points
299 Posts
Re: How to fill values of a dropdownlist by using selected index changed event of another dropdow...
Jun 12, 2012 01:29 PM|LINK
here is the Sample Code..
protected void ddlRewardType_SelectedIndexChanged(object sender, EventArgs e)
{
LoadScorecardNames();
}
private void LoadScorecardNames()
{
ddlScorecardName.DataTextField ="ScorecardName";
ddlScorecardName.DataValueField ="ScorecardId";
ddlScorecardName.DataSource = <<dataSource>>;
ddlScorecardName.DataBind();
}
Thats a Sample which I pulled from Code. Please try to implement in a similar Way.
Thanks
Srini
GeorgeTheOne
Member
24 Points
21 Posts
Re: How to fill values of a dropdownlist by using selected index changed event of another dropdow...
Jun 12, 2012 01:32 PM|LINK
Thanks nadellas!
How do i clear the values of the dropdownlist on selected index change of another dropdownlist?
nadellas
Participant
1218 Points
299 Posts
Re: How to fill values of a dropdownlist by using selected index changed event of another dropdow...
Jun 12, 2012 01:39 PM|LINK
<<dropdownListName>>.Items.Clear();
that clears the items in the DropDown.
Thanks
Srini
GeorgeTheOne
Member
24 Points
21 Posts
Re: How to fill values of a dropdownlist by using selected index changed event of another dropdow...
Jun 12, 2012 01:40 PM|LINK
I got it...
Learning many things since i'm new...
dropdown1.Items.Clear();
Thanks a lot every1!!!!!