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

RadGrid - Validation with DataBinding

2 Answers 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vijaianand
Top achievements
Rank 1
Vijaianand asked on 07 Sep 2011, 09:42 PM
Hi

I am looking to see whether RadGRid has inbuilt databinding validation. For example, if you have NOT NULL field and trying to insert the column with null, it should throw an error without any code. I see this exists in devexpress. It helps to bind the data and allow the validations to be binded against data fields instead of field validators. I hope this may be possible.

Let me know.

Vijai

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 08 Sep 2011, 04:51 AM
Hello VijaiAnand,

One suggestion is to use ItemDataBound event and check for the populated value.
C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem dataItem = e.Item as GridDataItem;
        if (dataItem["ColumnUniqueName].Text == "")
            //your code goes here
    }
}

Thanks,
Princy.
0
Vijaianand
Top achievements
Rank 1
answered on 08 Sep 2011, 02:34 PM
That's one of the ways of doing it. I was looking for something already inbuilt in the RadGrid which will take the databinding while inserting/updating the row.  It exists in DevExpress GridView but I was hoping for something similar. 

Vijai
Tags
Grid
Asked by
Vijaianand
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Vijaianand
Top achievements
Rank 1
Share this question
or