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

Radgrid add new record data checking

2 Answers 88 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bryan
Top achievements
Rank 2
Bryan asked on 04 Feb 2013, 04:36 PM
In a Radgrid, how do I keep the add new record open when someone clicks the save button and I check to make sure the data is all in the correct format or valid? I want the add new record to stay open after I tell them the data is not valid and also keep the values they have already entered.

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 05 Feb 2013, 05:02 AM
Hi,

Please take a look into the following code snippet I tried to keep the insert form open if correct value is not entered.

C#:
protected void rdgdr1_InsertCommand(object sender, GridCommandEventArgs e)
{
    GridEditableItem editItem = (GridEditableItem)e.Item;
    TextBox OrderText=(TextBox)editItem["UniqueName"].Controls[0]
     
    if (OrderText.Text=="correct")
    {
            
        //insert the data in the database
    }
    else
    {
        e.Canceled = true
    }
}


Another option is to use validator to check the input data. Please take a look into this documentation.

Thanks,
Shinu.
0
Bryan
Top achievements
Rank 2
answered on 05 Feb 2013, 01:43 PM
Thanks that worked perfectly.
Tags
Grid
Asked by
Bryan
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Bryan
Top achievements
Rank 2
Share this question
or