Click here to Skip to main content
15,917,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
sir i

when ever i m getting combobox after binding from database

C#
BusinessLayer blayar = new BusinessLayer();
            DataTable dt = blayar.getproductType(Global.CompanyId);
            cmbProType.DataSource = dt;
            if (dt.Rows.Count > 0)
            {
                cmbProType.DisplayMember = "Type";
                cmbProType.ValueMember = "id";
            }



and then Chenge index //code

C#
private void cmbProType_SelectedIndexChanged(object sender, EventArgs e)
        {
            bType = true;
            if (bType)
            {
                int counter;
                int id_ProductType=Convert.ToInt32(cmbProType.SelectedValue);// Getting  Error IConvetable System.row.RowDataView like this 
                BusinessLayer blayer = new BusinessLayer();
                DataTable dt = new DataTable();
                counter = blayer.ChecksubTypeofType(id_ProductType);
                if (counter > 0)
                {
                    dt = blayer.getProductSubtype(id_ProductType);
                    if (dt.Rows.Count > 0)
                    {
                        cmbProdSubType.DataSource = dt;
                        cmbProdSubType.DisplayMember = "Type";
                        cmbProdSubType.ValueMember = "id";
                    }

                }
                else
                {
                    dt = blayer.getProductByTypeID(id_ProductType);
                    DGviewList.DataSource = dt;
  
                 
                }
            }
            else
                bType = false;
        }


sir how to solve this problem
Posted
Updated 16-Oct-13 21:03pm
v2
Comments
thatraja 17-Oct-13 3:07am    
what's value of cmbProType.SelectedValue while debugging?

You have giving the data source to your Combo box, but you had not bind it Add one line to your code

BusinessLayer blayar = new BusinessLayer();
       DataTable dt = blayar.getproductType(Global.CompanyId);
       cmbProType.DataSource = dt;
       if (dt.Rows.Count > 0)
       {
           cmbProType.DisplayMember = "Type";
           cmbProType.ValueMember = "id";
       }
       cmbProType.dataBind();             // Add this line
 
Share this answer
 
Comments
Member 10315500 7-Nov-13 7:14am    
Thank you.... So Much
BusinessLayer blayar = new BusinessLayer();
            DataTable dt = blayar.getproductType(Global.CompanyId);
            cmbProType.DataSource = dt;
            if (dt.Rows.Count > 0)
            {
                cmbProType.DisplayMember = "Type";
                cmbProType.ValueMember = "id";
                cmbProType.DataBind();

            }



private void cmbProType_SelectedIndexChanged(object sender, EventArgs e)
        {
            bType = true;
            if (bType)
            {
                int counter;
                int id_ProductType=Convert.ToInt32(cmbProType.SelectedValue);// Getting  Error IConvetable System.row.RowDataView like this 
                BusinessLayer blayer = new BusinessLayer();
                DataTable dt = new DataTable();
                counter = blayer.ChecksubTypeofType(id_ProductType);
                if (counter > 0)
                {
                    dt = blayer.getProductSubtype(id_ProductType);
                    if (dt.Rows.Count > 0)
                    {
                        cmbProdSubType.DataSource = dt;
                        cmbProdSubType.DisplayMember = "Type";
                        cmbProdSubType.ValueMember = "id";
                         cmbProdSubType.DataBind();
                    }
 
                }
                else
                {
                    dt = blayer.getProductByTypeID(id_ProductType);
                    DGviewList.DataSource = dt;
                    DGviewList.DataBind();
                 
                }
            }
            else
                bType = false;
        }
 
Share this answer
 
Comments
Member 10315500 7-Nov-13 7:14am    
thank you so much
Tom Marvolo Riddle 7-Nov-13 8:08am    
welcome!
Member 10315500 15-Nov-13 8:34am    
not working in windows application in c# this Method the option in DataBind() but its give us Error :Error 10 'System.Windows.Forms.DataGridView' does not contain a definition for 'DataBind' and no extension method 'DataBind' accepting a first argument of type 'System.Windows.Forms.DataGridView' could be found (are you missing a using directive or an assembly reference?)

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



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