Naeem Khan

Naeem Khan

  • 982
  • 802
  • 801.3k

Problem in DataBinding with two Combo box using c#

Dec 30 2009 12:49 AM
hello every one,

i have very big problem i have 2 combo box which is bind from database when i m changing one combo box than its not working properly i dont know why its give me exception i m sending code of binding..  please check it now and reply me as soon as possible ...........

//code

 // show bank details for deposit bank 
        private void show_bank_info()
        {
            try
            {
                
                cb_bank_name.Items.Add("Select Bank Name");
                DataSet ds = new DataSet();
                ds = gBL.show_bank_name_place();
                DataRow r = ds.Tables[0].NewRow();
                r["Bank_Name"] = "Select Bank Name";
                ds.Tables[0].Rows.InsertAt(r, 0);
                cb_bank_name.DataSource = ds.Tables[0];               
                cb_bank_name.DisplayMember = "Bank_Name";
                cb_bank_name.ValueMember = "Bank_Id";
                cb_bsr_code.DataBindings.Clear();
                cb_bsr_code.DataBindings.Add("text", ds.Tables[0], "BSR_Code");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        // show bsr code 

        private void show_Bsr_Code()
        {
            try
            {
                cb_bsr_code.Items.Add("Select BSR Code");
                DataSet ds = new DataSet();
                ds = gBL.show_bank_name_place();
                DataRow r = ds.Tables[0].NewRow();
                r["Bsr_Code"] = "Select BSR Code";
                ds.Tables[0].Rows.InsertAt(r, 0);
                cb_bsr_code.DataSource = ds.Tables[0];
                cb_bsr_code.DisplayMember = "BSR_Code";
                cb_contract_description.ValueMember = "Bank_Id";
                cb_bank_name.DataBindings.Clear();
                cb_bank_name.DataBindings.Add("text", ds.Tables[0], "Bank_Name");
            }
            catch (Exception ex)
            {
              MessageBox.Show(ex.Message);
            }

        }

reply me as soon as possible 





Answers (1)