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

How can access to the NewRow cell text

5 Answers 95 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Masoud
Top achievements
Rank 1
Masoud asked on 03 Feb 2011, 01:02 PM
hi!
How can i access to the cells text of grid view NewRow .

Please see this Picture

also notice to follow block code,please:

private void radGridView1_RowValidating(object sender, RowValidatingEventArgs e)
{
    if (e.Row != null && e.RowIndex == -1 && e.Row.Cells["column1"].CellElement != null)
    {
        MessageBox.Show(e.Row.Cells["column1"].CellElement.Text);
    }
}

if RowValidating event raised with the keyboard the MessageBox show nothing but if the event raised by click on other rows MessageBox show the cell text.

5 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 04 Feb 2011, 11:55 AM
hello,

You can get to the row that is adding using the UserAddingRow event. Please consider the following code

this.radGridView1.UserAddingRow += new Telerik.WinControls.UI.GridViewRowCancelEventHandler(this.radGridView1_UserAddingRow);
private void radGridView1_UserAddingRow(object sender, GridViewRowCancelEventArgs e)
{
    MessageBox.Show(e.Rows[0].Cells["ColumnName"].Value.ToString());
}

I hope that helps but let me know if you have further questions
Richard
0
Masoud
Top achievements
Rank 1
answered on 05 Feb 2011, 08:35 AM
my dear friend:

this event does not support by RadGridView  control
and it is for DataGridView in Visual Studio Data Controls.

tnx a lot for your help
0
Richard Slade
Top achievements
Rank 2
answered on 05 Feb 2011, 09:45 AM
Hello,

The UserAddingRow event is part of RadGridView in the currnet release. Perhaps you are running an older version.
You can also get to the row using the RowsChanging event in the following way

this.radGridView1.RowsChanging += new Telerik.WinControls.UI.GridViewCollectionChangingEventHandler(this.radGridView1_RowsChanging);
private void radGridView1_RowsChanging(object sender, GridViewCollectionChangingEventArgs e)
{
    if (e.Action == NotifyCollectionChangedAction.Add)
    {
        MessageBox.Show(this.radGridView1.CurrentRow.Cells["ColumnName"].Value.ToString());
    }
}

Hope that helps
Richard

0
Richard Slade
Top achievements
Rank 2
answered on 07 Feb 2011, 05:02 PM
Hello,

Did this help? If so, please remember to mark as answer. If you need further assistance, please let me know.
Thanks
Richard
0
Alexander
Telerik team
answered on 09 Feb 2011, 10:06 AM
Hello Masoud,

Both suggestions given by Richard, work with the latest version of RadGridView - Q3 2010 SP1. Considering your code snippet, you are using an older version of the control - the CellElement is not accessible in this context in the latest release. I highly encourage you to update your project to the latest version of the controls.

Do not hesitate to write back if you have more questions.

Best regards,
Alexander
the Telerik team
Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
Tags
GridView
Asked by
Masoud
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Masoud
Top achievements
Rank 1
Alexander
Telerik team
Share this question
or