I would like to retrieve the value of whats stored in a currenlty selected row in my datagrid and store it in a string.

1. Is this possible?
2. If so how might I go about doing it

myDataGrid.Rows.Cell[0].etc.etc doesn't seem to work and it is all I could find on the internet

>Is this possible?

Yes. Use row index (int value) with myDataGrid.Rows[index].Cell[0].etc

I tried string

myString = myDataGrid.Rows[0].Cells[0].etc

and I get DataGrid has no method for Rows or something to that extent

Can I know which asp.net version are you using? Please post complete source code here.

Can I know which asp.net version are you using? Please post complete source code here.

string DataGridValue;
MainDataGrid.SelectedIndex = 0;
DataGridValue = ThisDataGrid.Rows[0].Cell[0].ToString();

ASP.NET Version# 3.0.50106.0

DataGridValue = ThisDataGrid.Rows[0].Cell[0].Text;
DataGridValue = ThisDataGrid.Rows[0].Cell[0].Text;

I get datagrid does not contain a definition for Rows

I think you should have to post source code.

See this code,

foreach (YourDataType item in ThisDataGrid.SelectedItems)
    {
          ....
    }

I think you should have to post source code.

See this code,

foreach (YourDataType item in ThisDataGrid.SelectedItems)
    {
          ....
    }

I would post the source code, but there is only so much I can post at work. Im a Mac guy most of the time so work is the only time I get access to c#

foreach (Object thisRow in MyDataGrid.SelectedItems)
                {
                    
                    StringTestTextBox.Text = thisRow.ToString();

                }
            }

returns the path to the class that stores the data

i.e MyProjectSolution.MyClass

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.