Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to get cell (Id No) value of selected datagrid row in Wpf
C#
ArrayList list = new ArrayList();

           for (int i = 0; i < myGrid.Items.Count; i++)
           {
               CheckBox mycheckbox = myGrid.Columns[5].GetCellContent(myGrid.Items[i]) as CheckBox;
               if (mycheckbox.IsChecked == true)
               {
                   int inde = this.myGrid.SelectedIndex;
                   DataRowView drv = (DataRowView)myGrid.Items[inde];
                   object ch = drv[1];

                   list.Add(ch);
               }
           }
Posted
Updated 30-Nov-14 5:06am
v2

it depends on how you have bind data to your grid, check below link for similar question and answers
Get selected row item in DataGrid WPF[^]
 
Share this answer
 
Comments
mukesh mourya 30-Nov-14 9:16am    
i has bind data grid bind from database using linq
here problem is that how can i check which data row are checked (checkbox) and how can i select this particular cell of that row
mukesh mourya 30-Nov-14 9:18am    
i saw many solution but no any solution was worked Properly
DamithSL 30-Nov-14 9:37am    
update question with your code
C#
for (int i = 0; i < myGrid.Items.Count; i++)
{
var item = myGrid.Items[i];
var mycheckbox = myGrid.Columns[5].GetCellContent(item) as CheckBox;
if ((bool)mycheckbox.IsChecked)
{
string ID = (myGrid.SelectedCells[1].Column.GetCellContent(item) as TextBlock).Text;
}
Massege.Show(ID);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900