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

How can I save value for a row in GridView

1 Answer 94 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 12 Jun 2019, 09:05 PM

Lets say I added a row, and a required field is missing, so I alert the user, I want to keep the values the same, but after the alert values disappear. Here is the code, how i tried to return values

 

01.if (!String.IsNullOrEmpty(newItem.stCountryName))
02.                dr.Cells["column1"].Value = newItem.stCountryName;
03.                //((CountryTable)dr.DataBoundItem).stCountryName = newItem.stCountryName;
04.            if (!String.IsNullOrEmpty(newItem.stCountryCode))
05.                ((CountryTable)dr.DataBoundItem).stCountryCode = newItem.stCountryCode;
06.            if (newItem.nCodeLen != null)
07.                ((CountryTable)dr.DataBoundItem).nCodeLen = newItem.nCodeLen;
08.            if (newItem.nRegionID != null)
09.                ((CountryTable)dr.DataBoundItem).nRegionID = newItem.nRegionID;

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 17 Jun 2019, 08:24 AM
Hello, Andrew,         

According to the provided information, it is not clear enough how exactly you show the alert for required fields. 

RadGridView provides a convenient way to perform validation before data is committed to the underlying data source. You can validate data by handling CellValidating event which is raised by RadGridView when the current cell changes or when the cell loses input focus (when pressing Enter key). Canceling this event prevents the user from exiting the cell until a valid editor value is entered or the edit process is canceled. Please refer to the following help article for further information: https://docs.telerik.com/devtools/winforms/controls/gridview/editors/data-validation

If you are still experiencing any further difficulties, it would be greatly appreciated if you can provide more information about the precise case and how exactly the grid is setup on your end. Providing some sample code snippet for the grid's initialization and data validation would be also quite useful. Thank you in advance for your cooperation.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Andrew
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or