Hi, I am facing a issue to find the ChildItem of the parent grid in ItemCreated event of Child grid after doing paging or filtering or sorting on parent grid.
Here is my code of OnNeedDataSource for Parent Grid :
public void GetInProcessData(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
EffortCertificationList effortCertifications = new EffortCertificationList();
if (Session["IPEffortCertifications"] != null)
{ effortCertifications = (EffortCertificationList)Session["IPEffortCertifications"]; }
else
{ effortCertifications.CurrEmployee = Session["currEmployee"].ToString();
effortCertifications.Load("InProcess");
Session["IPEffortCertifications"] = effortCertifications;
}
grdInProcess.DataSource = effortCertifications;
}
Here is my code of OnNeedDataSource for Child Grid which is in NestedViewTemplate :
protected void GetInProcesDetails(object source, GridNeedDataSourceEventArgs e)
{
GridDataItem parentItem = ((source as RadGrid).NamingContainer as GridNestedViewItem).ParentItem as GridDataItem;
string _employeeId = parentItem.GetDataKeyValue("Employee").ToString();
Label lblBeginDate = (Label)parentItem.FindControl("lblIPStartDate");
Label lblEndDate = (Label)parentItem.FindControl("lblIPEndDate");
EffortCertificationList objeffortCertifications = new EffortCertificationList();
if (Session["IPEffortCertifications"] != null)
{
objeffortCertifications = (EffortCertificationList)Session["IPEffortCertifications"];
var effortDetails = from ec in objeffortCertifications
where ec.Employee == _employeeId && ec.CertPeriodStartDate == Convert.ToDateTime(lblBeginDate.Text) && ec.CertPeriodEndDate == Convert.ToDateTime(lblEndDate.Text)
select ec;
EffortDetailList objEffortDetails = new EffortDetailList();
foreach (var ed in effortDetails)
{
objEffortDetails = ed.Details;
}
(source as RadGrid).AllowFilteringByColumn = false;
(source as RadGrid).DataSource = objEffortDetails;
}
protected void grdInProcesDetails_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
GridDataItem parentItem = ((sender as RadGrid).NamingContainer as GridNestedViewItem).ParentItem as GridDataItem;
if (parentItem != null && parentItem.ChildItem !=null)
{ string _employeeId = parentItem.GetDataKeyValue("Employee").ToString();
CheckBox chkIPReviewed = parentItem.ChildItem.FindControl("chkInProcessReviewed") as CheckBox;
}
}
}
Here in this event parentItem.ChildItem is null because of which i could not add attribute for calling javascript funcation for chkIPReviewed control. This is happening only after paging or sorting or filtering.
I am using client side function to expand or collapse for showing the Inner grid which is present in Nesstedviewtemplate.
Please provide me a solution.
Thanks in advance
Here is my code of OnNeedDataSource for Parent Grid :
public void GetInProcessData(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
EffortCertificationList effortCertifications = new EffortCertificationList();
if (Session["IPEffortCertifications"] != null)
{ effortCertifications = (EffortCertificationList)Session["IPEffortCertifications"]; }
else
{ effortCertifications.CurrEmployee = Session["currEmployee"].ToString();
effortCertifications.Load("InProcess");
Session["IPEffortCertifications"] = effortCertifications;
}
grdInProcess.DataSource = effortCertifications;
}
Here is my code of OnNeedDataSource for Child Grid which is in NestedViewTemplate :
protected void GetInProcesDetails(object source, GridNeedDataSourceEventArgs e)
{
GridDataItem parentItem = ((source as RadGrid).NamingContainer as GridNestedViewItem).ParentItem as GridDataItem;
string _employeeId = parentItem.GetDataKeyValue("Employee").ToString();
Label lblBeginDate = (Label)parentItem.FindControl("lblIPStartDate");
Label lblEndDate = (Label)parentItem.FindControl("lblIPEndDate");
EffortCertificationList objeffortCertifications = new EffortCertificationList();
if (Session["IPEffortCertifications"] != null)
{
objeffortCertifications = (EffortCertificationList)Session["IPEffortCertifications"];
var effortDetails = from ec in objeffortCertifications
where ec.Employee == _employeeId && ec.CertPeriodStartDate == Convert.ToDateTime(lblBeginDate.Text) && ec.CertPeriodEndDate == Convert.ToDateTime(lblEndDate.Text)
select ec;
EffortDetailList objEffortDetails = new EffortDetailList();
foreach (var ed in effortDetails)
{
objEffortDetails = ed.Details;
}
(source as RadGrid).AllowFilteringByColumn = false;
(source as RadGrid).DataSource = objEffortDetails;
}
protected void grdInProcesDetails_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
GridDataItem parentItem = ((sender as RadGrid).NamingContainer as GridNestedViewItem).ParentItem as GridDataItem;
if (parentItem != null && parentItem.ChildItem !=null)
{ string _employeeId = parentItem.GetDataKeyValue("Employee").ToString();
CheckBox chkIPReviewed = parentItem.ChildItem.FindControl("chkInProcessReviewed") as CheckBox;
}
}
}
Here in this event parentItem.ChildItem is null because of which i could not add attribute for calling javascript funcation for chkIPReviewed control. This is happening only after paging or sorting or filtering.
I am using client side function to expand or collapse for showing the Inner grid which is present in Nesstedviewtemplate.
Please provide me a solution.
Thanks in advance