Question : DataGrid Saving

Dear Experts

For the first time, I am working on a project involving Datagrid. This is a windows application with oracle database and programming language is C#.

My form design is as per attached screen shot.

Table name is taxgroup. I have created a binding source and table adapter. Table taxgroup has a colum taxid which is referenced to table tax

Problem for which I need solution

1.      user enters description, selects taxdescription, enters formula name & enters formula. Then user clicks on add. User can add n number rows in this way
                    Now when add is clicked, how do I add the data to grid ?2.      now when user clicks on save, complete grid data should be stored in database.
How do I achieve this.

Would be helpful if i get a proper code for this
Attachments:
 
 

Answer : DataGrid Saving

Hi
try this code in Add and Save button click events

private void btnAdd_Click(object sender, EventArgs e)
        {
            dataGridView1.Rows.Add();          
            dataGridView1.Rows[inindex].Cells[0].Value = txtdescription.Text;
            dataGridView1.Rows[inindex].Cells[1].Value = txtformulaname.Text;
            dataGridView1.Rows[inindex].Cells[2].Value = txtFormula.Text;
            inindex++;          
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow Row in dataGridView1.Rows)
            {
               /*take each cell value   like this
 value1=Row.Cells[0].Value;
value2=Row.Cells[1].Value,
value3=Row.Cells[2].Value; and Save to Database*/
            }
        }
Random Solutions  
 
programming4us programming4us