Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
two method for two combobox binding on a form

C#
private void cbBookBinding()
{
bHadithBook.DataSource = objSearch.SelectHadithBookName();
            cbHadithBook.DisplayMember = "Book_English_Name";
            cbHadithBook.ValueMember= "Book_Id";
           

            objSearch.HadithBookNo = Convert.ToInt32(cbHadithBook.SelectedValue);
}
 private void cbHadtihBaabBinding()
{

            cbBaab.DataSource = objSearch.SelectHadithBaabEnglish();
            cbBaab.DisplayMember = "[Baab_English_Name]";
            cbBaab.ValueMember = "[Baab_Id]";
           
            objSearch.HadithBookId = Convert.ToInt32(cbBaab.SelectedValue);



            dgvHadith.DataSource = objSearch.SelectHadithText();
}


i placed both method on event
1: combobox selected index change
and
2: For Load
this two method working find behind Form Load event
but on combobox selected index change this is not working. even i try to select another option from combbox but the one selected first remain selected in combobx. nothing change in combox and on gridview.
Posted

1 solution

check for asp page property for control, for dropdownlist put AutoPostback="True"
 
Share this answer
 
Comments
Muhamad Faizan Khan 7-Oct-13 9:32am    
window form
AnuragTripathi 9-Oct-13 3:00am    
you can put directly by putting cboTest.SelectedValue = 3
Means you can directly set selected value to a combobox by providing it explicitly after data bind.

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


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