0

I have a DataGridView, which has two columns and several rows. The first column has the names of some attributes of an object and the second one should be filled with values by the user.

How can I get the second column of a selected row automatically in editmode independent of the column, which is entered to select the row?
This means, if a row is selected it should be immediately possible to enter some values into the second column of that specific row, even if the row is selected by entering the first column of the row.

By now, the first column has the property DataGridRowColumns.ReadOnly = true and the second one has DataGridViewColumn.ReadOnly = false. The grid has the following properties: DataGridView.MultiSelect = false and DataGridView.SelectionMode = FullRowSelect.

ischas
  • 169
  • 2
  • 12
  • And your question is..? those properties have nothing to do with getting the value of a specific column in EditMode Are you wanting something like this for example `DataGridViewRow rowSelected = dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex];` – MethodMan Mar 21 '13 at 16:13
  • possible duplicate of [How to get Cell value of DataGridView by column name?](http://stackoverflow.com/questions/13436553/how-to-get-cell-value-of-datagridview-by-column-name) – MethodMan Mar 21 '13 at 16:18
  • I don't want the value of a specific column, I want a specific cell to be in editmode. I try to change the formulation of my post and change it to a question. – ischas Mar 21 '13 at 16:52
  • you need to edit your question Title to depict that otherwise you're going to get improper answers – MethodMan Mar 21 '13 at 16:54
  • Feel free to make any suggestions for a more proper title to my question. For me it's quiet hard to formulate it without making it a very long title. – ischas Mar 21 '13 at 17:05

1 Answers1

0

You can try with this code

protected void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
{

    if (e.Item.ItemType == ListItemType.EditItem)
    {
            DataRowView dataItem1 = (DataRowView)e.Item.DataItem;
            var result = (string)dataItem1.Row["YourColumnName"];
            ......
    }    }
Aghilas Yakoub
  • 28,516
  • 5
  • 46
  • 51