How to add Values from Data Grid view to Combo box
DataTable dt =new DataTable();
//DataTable dt = new DataTable();
dt.Columns.Add("ExiseINVNo", typeof(String));
//dt.Columns.Add("Money", typeof(String));
dt.Rows.Add(new object[] { " <--Select--> "});
//dt.Rows.Add(new object[] { "Ki", 30 });
foreach (DataGridViewRow _dgr in dgvSalesInvItems.Rows)
{
if (_dgr.Cells["ExciseInvoice_No"].Value != null)
{
string val = _dgr.Cells["ExciseInvoice_No"].Value.ToString();
dt.Rows.Add(new object[] { val});
}
}
//DataTable Dt1 = Masters.RemoveDuplicateRows(dt, "ExiseINVNo");
//DataRow dr = dt.NewRow();
//dr["Exise"] = "< -- Select -- >";
//DSItems.Tables[0].Rows.InsertAt(dr, 0);
cmbExciseInvNo.DataSource = Dt1;
cmbExciseInvNo.DisplayMember = "ExiseINVNo";
cmbExciseInvNo.SelectedIndex = 0;
DataTable dt =new DataTable();
//DataTable dt = new DataTable();
dt.Columns.Add("ExiseINVNo", typeof(String));
//dt.Columns.Add("Money", typeof(String));
dt.Rows.Add(new object[] { " <--Select--> "});
//dt.Rows.Add(new object[] { "Ki", 30 });
foreach (DataGridViewRow _dgr in dgvSalesInvItems.Rows)
{
if (_dgr.Cells["ExciseInvoice_No"].Value != null)
{
string val = _dgr.Cells["ExciseInvoice_No"].Value.ToString();
dt.Rows.Add(new object[] { val});
}
}
//DataTable Dt1 = Masters.RemoveDuplicateRows(dt, "ExiseINVNo");
//DataRow dr = dt.NewRow();
//dr["Exise"] = "< -- Select -- >";
//DSItems.Tables[0].Rows.InsertAt(dr, 0);
cmbExciseInvNo.DataSource = Dt1;
cmbExciseInvNo.DisplayMember = "ExiseINVNo";
cmbExciseInvNo.SelectedIndex = 0;
No comments:
Post a Comment