How can I save value for a row in GridView

2 posts, 0 answers
  1. Andrew
    Andrew avatar
    1 posts
    Member since:
    Jun 2019

    Posted 12 Jun 2019 Link to this post

    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;
  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3903 posts

    Posted 17 Jun 2019 Link to this post

    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.
Back to Top