This is a migrated thread and some comments may be shown as answers.

GETting values from added row

1 Answer 76 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 06 Aug 2008, 04:27 PM
I have another question in Q2 2008 I am using a grid and allowing the user to add new rows.  The user clicks add new row, adds his data.  How can I get the values out of that row.  THe datagridview is loaded by a datatable.  I would like to trigger an insert proc when ever the user leaves the new row.

Is this possible?

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 07 Aug 2008, 08:29 AM
Hello Eric,

Thank you getting back to me. Its very easy to implement this functionality with RadGridView. To do this you should subscribe to RowsChanged event (after filling the adapter)

    private void Form1_Load(object sender, EventArgs e) 
        { 
            this.invoicesTableAdapter.Fill(this.nwindDataSet.Invoices); 
 
            this.radGridView1.RowsChanged += new  GridViewCollectionChangedEventHandler(radGridView1_RowsChanged);            
        } 

and   

 void radGridView1_RowsChanged(object sender, GridViewCollectionChangedEventArgs e) 
        { 
            if(e.Action == NotifyCollectionChangedAction.Add)//proceed only if rows added 
            { 
 
                GridViewDataRowInfo newRow = ((GridViewDataRowInfo) e.NewItems[0]); 
                MyProc( nnewRow.Cells[0].Value.ToString(),newRow.Cells[1].Value.ToString()); 
            } 
        } 
 
 
 

Hope this helps. Don't hesitate to contact us if you have other questions.

Greetings,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Eric
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or