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

Extracting Cell Values

3 Answers 192 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Andrew Bromfield
Top achievements
Rank 2
Andrew Bromfield asked on 15 May 2007, 09:22 PM

Hello,

I am very familiar with the DataGridView control the .NET Framework provides.  I would like to use your GridView control, but I need to know how to reproduce the code below using your GridView for WinForms control:

string x = this.DataGridView.SelectedRows[0].Cells[0].Value.ToString();

I was trying to get there using the following approach:

this.dataGrid_PatientList.MasterGridViewInfo.Rows[0]...

Unfortunately, I'm not sure where to go from here or if it's even possible to achieve the results I am looking for.

Thank you in advance, your help is much appreciated.

Andrew

3 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 1
answered on 15 May 2007, 09:36 PM
I believe the following forum thread is related:

http://www.telerik.com/community/forums/thread/b311D-makka.aspx

Currently the code needed is something along the lines of:
GridViewRowInfo currentRow = radGridView1.MasterGridViewInfo.CurrentRow; 
 
GridViewDataRowInfo current = currentRow as GridViewDataRowInfo; 
DataRowView drow = current.DataRowView; 
MessageBox.Show(drow["Name"].ToString()); 
 

In SP1 which should be released tomorrow, this should be more streamlined.

0
Andrew Bromfield
Top achievements
Rank 2
answered on 16 May 2007, 04:30 PM
I have downloaded and installed SP1 in hopes of being able to select a row and get its value.  I used the following syntax, but CurrentRow is always null. 

Syntax:

string x = this.GridView.MasterGridViewInfo.CurrentRow.Cells["CustomerID"].Value.ToString();

What event should I be executing the above code in?

Thanks,

Andrew

0
Andrew Bromfield
Top achievements
Rank 2
answered on 16 May 2007, 07:33 PM
My apologies, the issue above ("CurrentRow is always null") was with my code.  The new controls (SP1) work great!!

Thank you,

Andrew
Tags
GridView
Asked by
Andrew Bromfield
Top achievements
Rank 2
Answers by
Kevin
Top achievements
Rank 1
Andrew Bromfield
Top achievements
Rank 2
Share this question
or