.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> .NET Framework >> Post New QuestionBookmark and Share Subscribe to Forum

Binding Values into to multiple Drop Down List

Posted By: Dhilip.R     Posted Date: November 27, 2010    Points:2   Category :.NET Framework
Hi,Experts

I Have a Dataset dsSubjects.Using that Dataset i 'm going to bind multiple Drop Down List of the same data.The data are also bind well. But my problem is When i Change the value in one Drop Down List, all the Drop Down List values are also Changing, Can any one help me Why it is?


Thank & Regards
Dhilip.R

Responses
Author: SureshM             
Posted Date: November 27, 2010     Points: 5   

hi,

I am also testing with two dropdowns with same data. its working fine.

my code.
ddl1.DataSource = dst.Tables[0];
ddl1.DataValueField = dst.Tables[0].Columns["ProductID"].ToString();
ddl1.DataTextField = dst.Tables[0].Columns["ProductID"].ToString();
ddl1.DataBind();

ddl2.DataSource = dst.Tables[0];
ddl2.DataValueField = dst.Tables[0].Columns["ProductID"].ToString();
ddl2.DataTextField = dst.Tables[0].Columns["ProductID"].ToString();
ddl2.DataBind();

Let me know your feedback..

Author: Dhilip.R             
Posted Date: November 30, 2010     Points: 5   

Hi,SureshM

You are right. But the problem is When I'm change a value in one Drop Down List it'll affect all other Drop Down Lists.


Thanks & Regards
Dhilip.R

Author: Syed Shakeer Hussain             
Posted Date: December 02, 2010     Points: 5   

Hi,
There might be a chance wiht PostBack Event.

Try to use IsPostBack in PageLoad...

Author: Dhilip.R             
Posted Date: December 02, 2010     Points: 5   

Hi,Syed Shakeer Hussain

You r right but this is a windows form

Thanks & Regards
Dhilip.R

Keep Postings...

Author: Syed Shakeer Hussain             
Posted Date: December 02, 2010     Points: 5   

Hi Dhilip,

You can avoid your problem by removing ComboBox SelectedIndexChanged Event as follows

comboBox2.SelectedIndexChanged -= new EventHandler(ComboBox_SelectedIndexChanged);


When you are using comboBox2 then add the selectedIndexChanged evetn as follows

comboBox2.SelectedIndexChanged += new EventHandler(ComboBox_SelectedIndexChanged);




Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend