Friday, January 28, 2011

Iterating a RadGrid view in silver light

private void Button1_Click(object sender, RoutedEventArgs e)


{

foreach(Player player in this.playersGrid.Items)

{

var row = this.playersGrid.ItemContainerGenerator.ContainerFromItem(player) as GridViewRow;

if(row.IsSelected)

{

//you may implement your custom logic here.

}

}

}

or we can use it at GridDatabound event  like

protected void RadGrid1_DataBound(object sender, EventArgs e)


{

foreach (GridDataItem item in RadGrid1.MasterTableView.Items)

{

bool oneValue = Convert.ToBoolean(item.GetDataKeyValue("status").ToString());

CheckBox chk = (CheckBox)item.FindControl("MyCheckBox");

chk.Checked = oneValue;

}

}

No comments:

Post a Comment