+ Reply to Thread
Results 1 to 2 of 2

Thread: data table with datagridview

  1. #1
    Newbie diane is an unknown quantity at this point
    Join Date
    Mar 2010
    Posts
    1

    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. #2
    Programming Expert gokuajmes will become famous soon enough gokuajmes will become famous soon enough gokuajmes's Avatar
    Join Date
    Jan 2010
    Location
    India
    Age
    22
    Posts
    350
    Blog Entries
    2

    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
    My Forum: http://forum.deeptechtons.net
    My Blog,Free wordpress,joomla,Drupal templates : http://donate.deeptechtons.net
    Earn points,Rob members points.Phpbb Installation service,Mod installation service.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

     

Similar Threads

  1. How to make DataGridView loads data faster ? (4000+ records)
    By capedech in forum Visual Basic Programming
    Replies: 1
    Last Post: 04-11-2010, 10:36 PM
  2. Replies: 16
    Last Post: 03-19-2010, 07:17 AM
  3. Multilanguage data (PHP data in MySQL table)
    By Thevenin in forum Database & Database Programming
    Replies: 0
    Last Post: 02-17-2010, 07:03 AM
  4. Load updated data to exisiting table
    By yonghan in forum AJAX
    Replies: 0
    Last Post: 10-28-2009, 07:08 PM
  5. Program to pass data from text file to table.
    By sania21 in forum Java Help
    Replies: 3
    Last Post: 05-28-2007, 05:32 AM