Getting the seltected rwo in the data grid from code behind in C#.
Suppose you give the name of data grid as dg;
Just do compy and paste of the below code you will get the row selected;
Suppose you give the name of data grid as dg;
Just do compy and paste of the below code you will get the row selected;
public class EmplyeeBAO
{
private ArrayList
GetSelectedRows(DataGrid dg)
{
ArrayList al = new
ArrayList();
CurrencyManager cm = (CurrencyManager)this.
BindingContext[dg.DataSource, dg.DataMember];
DataView
dv = (DataView)cm.List;
for(int i = 0; i <
dv.Count; ++i)
{
if(dg.IsSelected(i)) // find out the selected rwo
al.Add(i);
}
return al;
}
No comments:
Post a Comment