Query a Datagrid for selected items - Silverlight

Associate
Joined
27 Jan 2005
Posts
1,324
Location
S. Yorks
I have a datagrid, it has a templatecolumn that is a checkbox. The grid is populated from a list.

How can I query for which items have been selected, depending on which button is pressed I need to check to ensure only one item is selected, or use the selected items and print them.

regards,

Matt
 
Associate
Joined
13 Mar 2012
Posts
60
Location
Hartlepool
You need to iterate over the row collection from the data grid testing the values from the template column. You can get the contents of the cell your need using:

bool isChecked = (row.FindControl("checkBoxId") as CheckBox).Checked;

You then have to check whether only one item is checked (your first button) or add the checked row to a collection.
 
Back
Top Bottom