CodeKicks.com
Focus on Microsoft Technologies - Tutorials, Articles, Code Samples.

Monday, September 25, 2006

Getting Selected Rows in DataGrid in .NET

 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)) 
       al.Add(i); 
   } 
   return al; 
}

Post a Comment