/// Rows Check box check event.
///
///
///
protected void chkItemChecked_CheckedChanged(object sender, EventArgs e)
{
try
{
((sender as CheckBox).Parent.Parent as GridItem).Selected = (sender as CheckBox).Checked;
AssignedHeaderCheckBoxState((sender as CheckBox).Checked);
}
catch (Exception ex)
{
throw ex;
}
}
///
/// Header check box click event select/Unselect all rows.
///
///
///
protected void chkAllItems_CheckedChanged(object sender, EventArgs e)
{
try
{
if ((sender as CheckBox).Checked)
{
foreach (GridDataItem dataItem in RadGridCoverageAreaStates.MasterTableView.Items)
{
(dataItem.FindControl("chkItemChecked") as CheckBox).Checked = true;
dataItem.Selected = true;
}
}
else
{
foreach (GridDataItem dataItem in RadGridCoverageAreaStates.MasterTableView.Items)
{
(dataItem.FindControl("chkItemChecked") as CheckBox).Checked = false;
dataItem.Selected = false;
}
}
}
catch (Exception ex)
{
throw ex;
}
}
______________________
///
/// Check/Uncheck Header Check Box on the basis of all rows Selection/UnSelection.
///
///
private void AssignedHeaderCheckBoxState(bool bChecked)
{
int iCounter = 0;
DataTable dtCityList = ((DataSet)ViewState["ProductCovarageAreaStates"]).Tables[0]; ;
foreach (GridDataItem gdItem in RadGridCoverageAreaStates.Items)
if ((gdItem.FindControl("chkItemChecked") as CheckBox).Checked == bChecked)
iCounter++;
if (dtCityList != null)
{
if (iCounter == dtCityList.Rows.Count)
{
foreach (GridHeaderItem HeaderItem in RadGridCoverageAreaStates.MasterTableView.GetItems(GridItemType.Header))
{
((CheckBox)(HeaderItem.FindControl("chkAllItems"))).Checked = bChecked;
break;
}
}
else
{
foreach (GridHeaderItem HeaderItem in RadGridCoverageAreaStates.MasterTableView.GetItems(GridItemType.Header))
{
((CheckBox)(HeaderItem.FindControl("chkAllItems"))).Checked = false;
break;
}
}
}
}
No comments:
Post a Comment