Home All Groups Group Topic Archive Search About

How to get the index selected in the datagrid table

Author
16 Oct 2006 6:44 PM
anant
How to get the index selected in the datagrid table which contains the employees table information ,on getting the index who to update the record at that index in to other table
---
Posted via DotNetSlackers.com

Author
17 Oct 2006 8:33 AM
Michael Milonov
Hi!

If you want to get current row index from datagrid and then get this
row from DataTable you can use following code:

private BindingManagerBase bindingManagerBase;

public Form1()
{
......
......
//-----get binding context here-------------//
bindingManagerBase = dataGrid1.BindingContext[dataTable1];
}

//---------then you can use bindingManagerBase.Position to get row from
DataTable. Better to get row form DataView, because rows in DataGrid
can be sorted, filtered and etc...
void SomeMethod()
{
   dataTable1.DefaultView[bindingManagerBase.Position]["column1"] = 6;
}

Best Regards, Michael Milonov
http://www.snotratech.com

Show quote
> How to get the index selected in the datagrid table which contains the employees table information ,on getting the index who to update the record at that index in to other table
> ---
> Posted via DotNetSlackers.com

AddThis Social Bookmark Button