I have a tblItem which contains the following data
ItemID ItemName Qty Price Alert
1 abc 10 100 10
2 sky 10 100 10
3 xyz 10 100 10
I wrote the following code to display ItemName in the combo box inside DataGridview
private void frmDairy_Load(object sender, EventArgs e)
{
this.GetData();
dGVStore.AutoGenerateColumns = false;
}
private void GetData()
{
con = new SqlDbConnect();
con.SqlQuery("select ItemID,ItemName from tblMedicine order by MID desc;");
paging.SelectCommand = con.Cmd;
DataTable Medi = new DataTable();
paging.Fill(Medi);
this.cmbGName.DisplayMember = "ItemName";
this.cmbGName.ValueMember = "ItemID";
this.cmbGName.DataSource = Medi;
}
Required output
When I select ItemName abc from combo box inside datagridviw in colomn no. 2 then the colomn no. 3 , 4 and 5 should be auto fill by fetching data from database against ItemID = '1' and datagridview like that
ItemID ItemName Qty Price Alert
1 abc 10 100 10
and when in second row when i select ItemID= '2' sky from combo box then it should be
ItemID ItemName Qty Price Alert
2 sky 10 100 10
this process will continue untill i selects ItemName from combo box which may be 2 or 5 or many. how to get solution