2
Contributors
4
Replies
21
Views
2 Weeks
Discussion Span
Last Post by ddanbe
0

On the top of your new post you see some buttons. Click on the code button, paste your code in the window that opens.

0
DataTable dtabl = new DataTable();
        DataSet ds = new DataSet();
        DataSet dS = new DataSet();
        private void Form1_Load(object sender, EventArgs e)
        {

            string[] zones =ConfigurationManager.AppSettings["TimeZones"].Split(',');
            Timecombo.DataSource = zones;
            dS.ReadXml("xml.xml");
            dataGridView1.DataSource = dS.Tables[2];
            dataGridView1.Rows[0].Cells[0].Value=
            Departcombo.SelectedIndex = 0;
            DataGridViewButtonColumn btn = new DataGridViewButtonColumn();
            btn.Text = "Save";
            btn.UseColumnTextForButtonValue = true;
            dataGridView1.Columns.Add(btn);
            DataGridViewButtonColumn priority = new DataGridViewButtonColumn();
            priority.Text = "ALL Priority to 1";
            priority.UseColumnTextForButtonValue = true;
            dataGridView1.Columns.Add(priority);
            DataGridViewButtonColumn createparts = new DataGridViewButtonColumn();
            createparts.Text = "Create Parts";

            createparts.UseColumnTextForButtonValue = true;
            dataGridView1.Columns.Add(createparts);

            label3.Visible = false;
            label5.Visible = false;
            label7.Visible = false;
            btnsave.Visible = false;
            btnClose.Visible = false;

        }

        private DataTable GetDataTableFromDGV(DataGridView dataGridView1)
        {
             var dt = new DataTable();
            foreach (DataGridViewColumn column in dataGridView1.Columns)
            {
                 if (column.Visible)
                 {
                     dt.Columns.Add(column.HeaderText);
                 }
            }

             object[] cellValues = new object[dataGridView1.Columns.Count];
             foreach (DataGridViewRow row in dataGridView1.Rows) 
            {
                    for (int i = 0; i < 9; i++) 
                       {
                            cellValues[i] = row.Cells[i].Value;
                       }
                        dt.Rows.Add(cellValues);
            }

                    return dt;
        }
0

Line 2 ds, line3 dS. This is calling for disaster. Give meaningful name to ALL your variables. I could never infer in my life what ds or dS are standing for.

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.