Hi,
I generated one question paper with datagrid in silverlight. i done paging with datapager control. now i am displaying 5 questions per page. now i selected answer ie radiobutton for each question .now i want to find out which question is selected in that datagrid.can anybody please help me.
Thanks
P.Nagaraju
Loading
nagarajuPosted Aug 17, 2011, 7:18 AM
foreach (GridViewRow gvrow in GV_Questionpaper.Rows)
{
index = (int)GV_Questionpaper.DataKeys[gvrow.RowIndex].Value;
bool result1 = ((RadioButton)gvrow.FindControl("RBtn_Option1")).Checked;
bool result2 = ((RadioButton)gvrow.FindControl("RBtn_Option2")).Checked;
bool result3 = ((RadioButton)gvrow.FindControl("RBtn_Option3")).Checked;
bool result4 = ((RadioButton)gvrow.FindControl("RBtn_Option4")).Checked;
in asp.net i can find the control in gridview. likewise i want to find the radiobutton control from datatemplate of listbox in silverlight
Thanks
P.Nagaraju
Priya LingePosted Aug 17, 2011, 2:50 AM
We have Datagrid_LoadingRow in silverlight ,with the help of that you get the each row in datagrid after paging.
Customerdatagrid.LoadingRow += new EventHandler
void Customerdatagrid_LoadingRow(object sender, DataGridRowEventArgs e)
{
// CustomerDetail is a table at service side
ServiceReference1.CustomerDetail clist = e.Row.DataContext as ServiceReference1.CustomerDetail;
DataGridRow dataGridrow = DataGridRow.GetRowContainingElement(e.Row);
//here you will get content of each row
FrameworkElement el;
// Here i just take 1 column you can take what you want
el = this.Customerdatagrid.Columns[1].GetCellContent(e.Row);
DataGridCell changeCell = GetParent(el, typeof(DataGridCell)) as DataGridCell;
}
private FrameworkElement GetParent(FrameworkElement child, Type targetType)
{
object parent = child.Parent;
if (parent != null)
{
if (parent.GetType() == targetType)
{
return (FrameworkElement)parent;
}
else
{
return GetParent((FrameworkElement)parent, targetType);
}
}
return null;
}
Hope this will help you.
Thanks.