Binding gridview to Database table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sbandalli
    New Member
    • Feb 2009
    • 53

    Binding gridview to Database table

    Hi,

    I have a datagridview1, which has a comboboxcolumn categoryname(wh ich is binded to a database table Category )

    listCol.DataSou rce = cDS.Tables["Category"];

    datagridview1 also has two textbox column named description and amount which are not binded to any datasource.

    Now I want to bind this datagridview1 to a new database table called transact_table, so that whatever the user selects from the combboxcolumn and whatever the user types in the textbox of the datagridview has to be written in my database table transact_table.

    this is how I am trying:

    Code:
     SqlDataAdapter transactDataAdapter = new SqlDataAdapter("select * from Transact_table", connection);
              //DataTable pTable1 = cDS.Tables["Table"];
              DataTable pTable1 = new DataTable();
              transactDataAdapter.Fill(pTable1);
              dataGridView1.DataSource = cDS.Tables["Table"];
            transactDataAdapter.Update(pTable1);
    this code is not working.
Working...