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

gridview validating

1 Answer 146 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mihai Velicu
Top achievements
Rank 1
Mihai Velicu asked on 30 Mar 2010, 05:46 PM
Hi !

I have a hierarchical grid view. In the Child grid I press add new row . When I try to validate that row in Validating event I cannot read any of this row fields values. All are null.
Do you have any example regarding new rows validating and how to read valued from the new rows. Because the values are on the screen but cannot be read through the code. I can read the values for already in grid rows but for this new row I can't .
The video example in Support web page  with grid validation is working only when edit already in database rows, if you try the same example for a new row is not working  !

Regards,
Mihai


1 Answer, 1 is accepted

Sort by
0
Accepted
Svett
Telerik team
answered on 06 Apr 2010, 07:46 AM
Hi Mihai Velicu,

Thanks for contacting us and for your question.
When you are trying to access field values of new row, you should access field values of its DataRowInfo property. This is a limitation that we will address in some of the next major releases. Hence, you can access field value through GridViewNewRowInfo's Cells collection instead of its DataRowInfo's Cells collection.

You can use the following code snippet as sample how you can access row fields on RowValidating:

private void radGridView_RowValidating(object sender, RowValidatingEventArgs e)
{
    GridViewDataRowInfo dataRow = null;
    GridViewNewRowInfo newRowInfo = e.Row as GridViewNewRowInfo;
 
    if (newRowInfo != null)
    {
        dataRow = newRowInfo.DataRowInfo as GridViewDataRowInfo;
    }
    else
    {
        dataRow = e.Row as GridViewDataRowInfo;
    }
 
    if (dataRow == null)
    {
        return;
    }
 
    object value = dataRow.Cells["Column"].Value;
     
}


If you have further questions do not hesitate to write us back.

All the best,
Svett
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.
Tags
GridView
Asked by
Mihai Velicu
Top achievements
Rank 1
Answers by
Svett
Telerik team
Share this question
or