Re: Mapping from DataGridView to the actual DataRow

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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@xxxxxxxxxxxxxxx> wrote in message
news:uoCGUDznFHA.2444@xxxxxxxxxxxxxxxxxxxxxxx
> 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


.



Relevant Pages

  • Mapping from DataGridView to the actual DataRow
    ... I have a DataGridRow which i fill with data from a DataAdapter. ... of the first cell in the selected row, but this is not what I want. ... "If you know the enemy and know yourself, you need not fear the result ... of a hundred battles. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Newbie: Finding the position of a DataRow in a DataGrid thats sorted.
    ... What I want to do is determine the row number in a DataGrid that coresponds ... to a DataRow in the associated DataTable. ... if the user sorts the DataGrid these numbers no longer match. ... I'm not looking to find the DataRow for the currently selected row. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Which DataRow is selected in a DataGrid?
    ... If what you need is a reference to the DataRow from the DataTable as opposed ... > I have implemented a MouseUp event handler for this DataGrid that permits ... > and I have added code that retrieves the information from the selected row ... If I sort the data, however, I am unable to ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Newbie: Finding the position of a DataRow in a DataGrid thats sorted.
    ... > to a DataRow in the associated DataTable. ... The DataGrid's row should correspond with DataView index. ... > if the user sorts the DataGrid these numbers no longer match. ... I'm not looking to find the DataRow for the currently selected row. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Retreiving the DataRow from a Sorted DataGrid
    ... You can use the CurrencyManager to get the DataRow; ... Visit www.syncfusion.com for the coolest tools ... the DataRow for the currently selected row in the datagrid. ...
    (microsoft.public.dotnet.framework.windowsforms)