So i create popup Edit form, and i want to display connected rows in this popup also. For this i use Repeater with datasource and update datasource select comand each time when user opens Edit form:
Init of edit form:
case "Edit":
{
var sourceKeyValue = DataUtils.GetInt64(grid.GetRowValues(e.VisibleIndex, grid.KeyFieldName));
var resource = worker.ResourcePlanningViews.First(rpv => rpv.ID == sourceKeyValue);
Session["VisibleIndex"] = e.VisibleIndex;
Session["DateFrom"] = resource.DateFrom;
Session["DateTo"] = resource.DateTo;
this.userPlanings.SelectCommand = string.Format(@"Select [T0].id,
DateFrom, DateTo,
[T0].Description,
[T1].Name AS Project,
[T2].Name AS Company,
[T0].BookingPercentage
from[dbo].[WP_Topic_ResourcePlanning] as [T0]
Join WP_BaseData_Project as [T1] on[T0].ProjectID = [T1].id
Join WP_BaseData_Company as [T2] on[T1].CompanyID = [T2].id
where UserID in (
SELECT UserID
FROM[dbo].[WP_Topic_ResourcePlanning]
where id = {0})
and[T0].id != {0}
and (
[T0].DateFrom BETWEEN (@DateFrom) and (@DateTo)
or
[T0].DateTo BETWEEN (@DateFrom) and (@DateTo))", resource.ResourcePlanningId);
grid.StartEdit(e.VisibleIndex);
}
Data Source:
<asp:SqlDataSource ID="userPlanings" runat="server" ConnectionString="<%$ ConnectionStrings:WebPortalConnectionString %>">
<SelectParameters>
<asp:SessionParameter Name="DateFrom" SessionField="DateFrom" DefaultValue="2/22/2012" Type="String" />
<asp:SessionParameter Name="DateTo" SessionField="DateTo" DefaultValue="7/22/2020" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
After value in edit form changes i want to update repeater in pupup, for that i was trying to handle callback from ASPxCallbackPanel and update Session values with fresh date:
protected void HandleDateTimeCallback(object sender, CallbackEventArgsBase e)
{
var gridCntrl = this.gridResourcePlanningsCtrl.GridControl;
var callbackPanel = (ASPxCallbackPanel)gridCntrl.FindEditFormTemplateControl("editFormPanelCtrl");
int visibleIndex = (int)Session["VisibleIndex"];
var sourceKeyValue = DataUtils.GetInt64(gridCntrl.GetRowValues(visibleIndex, gridCntrl.KeyFieldName));
var resource = worker.ResourcePlanningViews.First(rpv => rpv.ID == sourceKeyValue);
var dateFrom = (DateTime)this.GetCtrlValue("dtDateFrom", callbackPanel);
var dateTo = (DateTime)this.GetCtrlValue("dtDateTo", callbackPanel);
Session["DateFrom"] = dateFrom;
Session["DateTo"] = dateTo;
gridCntrl.StartEdit(visibleIndex);
}
it isn't working. Error message when i'm tryong to gridCntrl.StartEdit(visibleIndex):
System.InvalidOperationException: 'Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.'
Also i was trying to use Update Panel, but i had server Error "Type 'System.Web.UI.UpdatePanel' does not have a public property named 'Repeater'"
Solution was to use List data source and update it each request
repeater.DataSource = resources.Count() == 0 ? null : resources;
repeater.DataBind();