Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

how do fill datagridview combobox column using sql on selection of other datagridview comboboxcolumn, here is my database with two column groupwise & itemwise

$
0
0
dear sir,

how do fill datagridview combobox column using sql on selection of other datagridview comboboxcolumn, here is my database with two column groupwise & itemwise
groupwiseitemwise
CABLE      - LAN CABLE CAT-6
CABLE       -POWER CABLE HEAVY 1.5 MT
CABLE       -VGA CABLE 1.5 M
CONNECTOR-RJ-45
MODEM       -D-LINK MODEM 14.4 MBPS DATA CARD
MODEM       -I-BALL MODEM 7.2 MBPS 3.5G DATA CARD
CABINET       -INTEX CABINET
CPU       -INTEL CORE I5 3RD GEN
CPU       -INTEL CORE I3 3RD GEN
CPU       -INTEL DUALCORE 3RD GEN
RAM       -TRANSCEND DDR3 4GB
RAM       -TRANSCEND DDR3 2GB

and my c# code is as fallows

 private void gdvpurches_SelectionChanged(object sender, EventArgs e)
        {
            try
            {

                cn.Open();

                for (i = 0; i <= gdvpurches.Rows.Count - 2; i++)
                {
                    group = Convert.ToString(gdvpurches.Rows[i].Cells[1].Value);
                    cmd = new SqlCommand("select itemwise from yeeessort where groupwise='" + group + "'", cn);
                    dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        cbitemname.Items.Add(dr[0]);
                        

                    }
                    dr.Close();
                    cbitemname.Items.Clear();
                }
               
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {

                cn.Close();
            }
        }


when i run this code   cbitemname.Items.Add(dr[0]); get filled all itemname of all rows on selection on groupwise field

please help us

thanks....

Viewing all articles
Browse latest Browse all 2535

Trending Articles