Thursday, 16 January 2014

How to add Values from Data Grid view to Combo box

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;

No comments:

Post a Comment

SQL SERVER – Disk Space Monitoring – Detecting Low Disk Space on Server

CREATE PROCEDURE [CSMSDVLP].[DiskSpaceMonitor] @mailProfile nvarchar(500), @mailto nvarchar(4000), @threshold INT, @logfile nvarchar(40...