Click here to Skip to main content
12,402,202 members (49,844 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB ASP.NET
Hello Everyone,

Page Structure
Page -> Place Holder -> web User control -> Dropdownlists

This is my Page Elements. There is click event to generate new webUserControl and place it onto PlaceHolder.
Now my Problem is that
I have three Dropdownlist inside webUserControl
and all values of dropdownlist populates from xml files.

Here is some Images to clarify my Problem
"All are inside WebUserControl which will created dynamically on the occurance of Click event"

1) suppose this is my first Drop down list -> i) DropdownlList

2) Now suppose I am selected "verb" option from dropdownlist1 automatically other dropdownlist2 will be visible and populates items in it according to dropdownlist1 selection

3) **Now main Problem starts here, **
when I am clicked on "Auxiliary" option, I am supposed to get index of Auxiliary text. It is 3. but it always returns index 0

this dropDownList does not hold the selected value.

Please give suggesions to resolve this problem.
Thanking you
Posted 11-Apr-13 0:36am
CHill60 11-Apr-13 6:44am
Sounds similar to an issue I had where the page was refreshing before I captured the selectedIndex - if I recall I had to check Page.IsPostBack
vinodkumarnie 14-Apr-13 13:08pm
Can you share your source code..?
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The problem is you are filling your 1st drop-down list in form load and every time some event happens it loads the form i guess u have not kept update panel so again it fills your first drop down and causes selected index changed event to fire which makes your dropdown2 selected index 0 again and again.

so my suggestion is you keep filling of your first drop down as following in form load

if(!IsPostback) then
//fill your drop-down 1 here
end if

i guess it helps you
Rate this: bad
Please Sign up or sign in to vote.

Solution 3


If Not IsPostBack Then

' here do u dropdown data bind work

End If
Marcus Kramer 15-Apr-13 9:15am
Please read the other answers before reposting what is already stated in an existing one.
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

Thank you so much to all.
Mr. Raj Sir You are absolutely right. controls getting refresh on each page load event.
even I applied update panel in my web use control but no use.

Mr. Babu Sir, Sorry but It will not work for my control.

I have solved my problem.

Actually , as I said I am creating my dynamic control in the occurrence of click event and placed in place holder.
and placeholder clears on each postback and then again load then web User Control. Due to this dropdownlist2 which dependent on dropdownlist1 gets refresh and cleared all values.

Solution :
write OnInit () method and inside that call function for filling up the values of dropdownlist1.
Postback cant reflects on dropdownlist1.

It works fine.

thanking you sir
Not an answer, should be deleted.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 19 Apr 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100