Add New Row - Winforms GridView Event

Hello, this is probably a really simple question, but I can't figure it out right now. I'm using the Winforms GridView control, and I want to be able to add a new row within the gridview control. I do have "AllowAddNewRow" set to true. Which event is being initiated when you add a new row to the grid? I easily was able to use the "RowDeleting" event when I delete a row, so I figure that there would be a "RowAdding" or a "RowAdded" event. But, there wasn't. I simply want to Add/Update/Delete rows. It's pretty simple with the ASP.NET control with the Insert,Update,Delete command events, but I can't seem to find anything similar in the winforms control. So, which event is used to Update a row, and which event is used to Add a new row (I want to be able to add the new row using the "click here to add new row" area), or what is the process to implement these 2 events?

I'm using the Q3 2007 V5 version.

thanks,
monirak

Jack

Unfortunately, RadGridView doesn't support the RowAdding and the RowAdded events at this time. We will add such events in our upcoming release Q1 2008. I suggest using the ListChanged event of your currency manager.

When a value in some cell is changed, the ValueChanged event of the RadGridView is fired.

Jack

The ValueChanged event is only fired when a value is changed. You should process this event, if you wish to track updates in RadGridView.

There is no specific event in RadGridView, that is fired when a row is inserted. As I mentioned in the previous post, we will correct this in our upcoming release Q1 2008. You can work around the issue by processing the ListChanged event. Refer to the code snippet below:

Jack

You should use the RowsChanging and RowsChanged events for this purpose. The Action property of the event arguments contains information whether the row was added or removed, and the NewItems array contains the affected rows.

Should you have any questions, I will gladly answer them.

All the best,
Jack
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.

hugo

Hi. my name is hugo.
Im having a similar problem when updating a radgridview value in a cell.
I'm using the latest package (WinForms Q3 2008). I set the grid to allow updating, it lets me change the value on the grid but when I check the db the value is not changed.
Do you have some code showing in VB how to change the values on the grid and post them back to the DB.
Thanks in advance

hugo

Ferry v.d. Graaf

If I use the RowChanging or RowChanged event, I don't get the new cell values. I try to insert a new row, direct after inserting I need the cell values. The NewItems array only contains "Nothing" values.

shuyin ngo

My name's Alvin,
I still didn't get it. After reading the above comments, i got a mess inside my head. I'm new to Telerik and Im using the trial version of Telerik Q1 2010.
Is there another way to add a new row into our DB using the "Click here to add a new row" and the CreateRow event? :"(

Julian Benkov

You can bind a DataTable object to RadGridView control. After that you can insert/edit/remove rows from the grid which will be automatically refreshed when bound to a DataTable object.

For database updates you must use the ADO.NET DataAdapter object. More information how to use ADO.NET objects for database operations you can find in this online tutorial.

Sincerely yours,
Julian Benkov
the Telerik team

Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items.

Rakesh

I am not able to update/insert/delete the data of database table which is bounded to a radgridview by selecting the Data Source for it.
The changes which i make in the gridview, i want that to be reflected in the database table automatically or on a button click, which i could not so please help me and give me code for it in c#.
The database I am using is Sql.

Julian Benkov

Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items

John Davis

Richard,
Thanks. But I do not see how your code could help because it pertains to a whole row. I ihave a column Userid that is a primary key.
So when the user UPDATES, this Userid column should be read-only, and the user can change only the other columns.
When the user INSERTS, then NONE of the columns should be read-only.
John

John Davis

Richard, This technique works perfectly. I really appreciate your posting it.
It seems this is a very common scenario, but it is not obvious how to do it, so your post will probably benefit many others.
John

You're welcome. Glad I could help. though I will go over it again when I have a moment, as I've realised that this doesn't account for tabbing through the items. For exmaple, if you are on the new row section and are editing a cell, ready to add, you cannot tab into the read only cell. Instead you must click on it. I'll let you know a workaround for that as soon as I can
Richard

Stephen Breytenbach

Hi Richard,
Using WinForms, Q1, 2011
I am attempting the same solution, I have a load on Demand grid, master and child, the Child expands with data correctly, when i click on the Add New Row part, (or any where in the child for that matter), my RowIndex is always -1,

Stephen Breytenbach

Hi Richard,
thanks for the swift reply, my problem, I gather, is that it is unbound data, ie I build the Child Grid, Ie, the Data Rows are not linked to a database, would this explain why the RowIndex is -1, even when I click on one of the other (populated) rows? (see attached section of how i populate the child grid)

I need to somehow trigger your solution, but only on the new row, and not the already populated rows (if that makes sense)

Julian Benkov

In the Load-On-Demand scenario the RowIndex property is not synchronized with the source collection. For your needs in this scenario you can use ChildRows.IndexOf() method of GridViewTemplate or the parent GridViewRowInfo.

I hope this helps.

Kind regards,

Julian Benkov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.