Hi,

I have a DataGridRow which i fill with data from a DataAdapter. Now
when the user selects a row in the grid, how do I find out which row
datarow in the dataset is "selected"?

I got this to work in asp.net 1.1 fairly easy, but how do i do it in
winforms 2.0?

I know I can just use SelectedRows[0].Cells[0].Value to get the value
of the first cell in the selected row, but this is not what I want.

What I basically want, is to be able to know which DataRow each
DataGridViewRow represents.

--
Thomas Due
Posted with XanaNews version 1.17.5.9

"If you know the enemy and know yourself, you need not fear the result
of a hundred battles. If you know yourself but not the enemy, for every
victory gained you will also suffer a defeat. If you know neither the
enemy nor yourself, you will succumb in every battle."
-- Sun-Tzu

Re: Mapping from DataGridView to the actual DataRow by Dave

Dave
Mon Aug 15 12:24:23 CDT 2005

If your using the DataRowChangeEventHandler then the
DataRowChangeEventArgs.Row property will contain the current DataRow.
Example:

theTable.RowChanged += new DataRowChangeEventHandler(theTableRowChanged);

private void theTableRowChanged(object sender, DataRowChangeEventArgs e)
{
DataRow theSelectedRow = e.Row;
}

hope that helps

"Thomas Due" <tdue@mail_remove_.dk> wrote in message
news:uoCGUDznFHA.2444@tk2msftngp13.phx.gbl...
> Hi,
>
> I have a DataGridRow which i fill with data from a DataAdapter. Now
> when the user selects a row in the grid, how do I find out which row
> datarow in the dataset is "selected"?
>
> I got this to work in asp.net 1.1 fairly easy, but how do i do it in
> winforms 2.0?
>
> I know I can just use SelectedRows[0].Cells[0].Value to get the value
> of the first cell in the selected row, but this is not what I want.
>
> What I basically want, is to be able to know which DataRow each
> DataGridViewRow represents.
>
> --
> Thomas Due
> Posted with XanaNews version 1.17.5.9
>
> "If you know the enemy and know yourself, you need not fear the result
> of a hundred battles. If you know yourself but not the enemy, for every
> victory gained you will also suffer a defeat. If you know neither the
> enemy nor yourself, you will succumb in every battle."
> -- Sun-Tzu



Re: Mapping from DataGridView to the actual DataRow by Thomas

Thomas
Tue Aug 16 01:04:05 CDT 2005

Dave Hagerich wrote:

> If your using the DataRowChangeEventHandler then the
> DataRowChangeEventArgs.Row property will contain the current DataRow.
> Example:
>
> theTable.RowChanged += new
> DataRowChangeEventHandler(theTableRowChanged);
>
> private void theTableRowChanged(object sender, DataRowChangeEventArgs
> e) {
> DataRow theSelectedRow = e.Row;
> }
>
> hope that helps

Unfortunately, it doesn't. Im working with the DataViewGrid in .net 2.0
on a winform. It does not have a RowChanged event.


--
Thomas Due
Posted with XanaNews version 1.17.5.9

"There is always some madness in love. But there is also always some
reason in madness."
-- Friedrich Nietzsche

Re:Mapping from DataGridView to the actual DataRow by David

David
Thu Jun 08 03:25:08 CDT 2006

Hi,

I was struggling with the same and got a solution from another developer.

On a DataGridViewRow is a property called DataBoundItem of type object.

This will contain a DataRowView (for certainty you can check this)

Once u got the DataRowView you can take the .Row and you got it

Works in 2.0

greetings
David