Closed Thread
Results 1 to 2 of 2

Thread: data table with datagridview

  1. #1
    diane is offline Newbie
    Join Date
    Mar 2010
    Posts
    1
    Rep Power
    0

    Question data table with datagridview

    hi i have a button that enters some values from a datagridview1 to another datagridview2. Now the problem is that when i click the button it gives me the values of the datagridview1 to datagridview2 but now the problem is that if i press again the button for other values it writes it in the same row. i tried the datatable.newrow but not working :/ :S

    Code:
    public void AddtoBill(DataGridView dgv)
            {
                DataGridViewRow row = dgv.SelectedRows[0];
                string a = row.Cells[0].Value.ToString();
                string b = row.Cells[1].Value.ToString();
                
                DataTable dt2 = new DataTable();
                
                dt2.Columns.Add("Product");
                dt2.Columns.Add("Price");
                dt2.Rows.Add(a,b);
                dt2.NewRow();
                dgvBill.DataSource = dt2;
    }

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    gokuajmes's Avatar
    gokuajmes is offline Programming God
    Join Date
    Jan 2010
    Location
    India
    Posts
    516
    Blog Entries
    5
    Rep Power
    12

    Re: data table with datagridview

    this is how its done ,
    declare a new row.

    Code:
    DataGridviewrow newRow=new DataGridviewRow();
    Code:
    dgvBill.DataSource = dt2;
    dgvBill.DataBind(); // you forgot this

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Binding data from SQL database to dataGridView control
    By Tonchi in forum C# Programming
    Replies: 11
    Last Post: 08-21-2011, 04:17 AM
  2. Replies: 1
    Last Post: 03-29-2011, 02:35 AM
  3. Data are not showing in DataGridView (VB.NET 2008 & Access 2010)
    By Ramroma in forum Visual Basic Programming
    Replies: 0
    Last Post: 01-25-2011, 02:47 AM
  4. How to make DataGridView loads data faster ? (4000+ records)
    By capedech in forum Visual Basic Programming
    Replies: 1
    Last Post: 04-11-2010, 11:36 PM
  5. Multilanguage data (PHP data in MySQL table)
    By Thevenin in forum Database & Database Programming
    Replies: 0
    Last Post: 02-17-2010, 07:03 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts