我在回调模式下有分层数据网格。
<ComponentArt:DataGrid ID="dgBL" runat="server" AllowColumnResizing="true" EmptyGridText="There is no data to display!"
LoadingPanelPosition="MiddleCenter" PagerStyle="Numbered" RunningMode="Callback" SearchOnKeyPress="true"
ShowFooter="true" ShowHeader="true" ShowSearchBox="true" AutoTheming="true" PreloadLevels="false"
GroupingNotificationText="Business Lines and their Departments" FillContainer="false" Width="60%"
Height="468px" AllowVerticalScrolling="true" AllowMultipleSelect="false">
<Levels>
<ComponentArt:GridLevel AllowGrouping="false" DataKeyField="BLID" AllowReordering="false">
<Columns>
<ComponentArt:GridColumn DataField="BLID" Visible="false" Width="1" />
<ComponentArt:GridColumn DataField="Name" HeadingText="Business Line Name" Visible="true" />
<ComponentArt:GridColumn DataField="DepartmentCount" HeadingText="Department Count" Visible="true" Width="140" />
<ComponentArt:GridColumn DataField="IsActive" HeadingText="Is Active" Visible="true" Width="80" />
<ComponentArt:GridColumn Align="Center" AllowSorting="False" DataCellServerTemplateId="AddDepartmentTemplate"
HeadingText="Add Department" Width="100" />
</Columns>
</ComponentArt:GridLevel>
<ComponentArt:GridLevel AllowGrouping="false" DataKeyField="DepartmentID" AllowReordering="false">
<Columns>
<ComponentArt:GridColumn DataField="DepartmentID" Visible="false" Width="30" />
<ComponentArt:GridColumn DataField="DepartmentName" HeadingText="Department Name" Visible="true" />
<ComponentArt:GridColumn DataField="Transit" HeadingText="Transit" Visible="true" Width="80" />
<ComponentArt:GridColumn DataField="BLID" Visible="false" Width="30" />
<ComponentArt:GridColumn DataField="IsActive" HeadingText="Is Active" Visible="true" Width="80" />
<ComponentArt:GridColumn Align="Center" AllowSorting="False" DataCellServerTemplateId="EditDepartmentTemplate1"
HeadingText="Edit" Width="80" />
</Columns>
</ComponentArt:GridLevel>
</Levels>
<ServerTemplates>
<ComponentArt:GridServerTemplate ID="AddDepartmentTemplate">
<Template>
<asp:ImageButton ID="addNewDepartment" runat="server" ImageUrl="~/App_Themes/OnlineForms/Images/add.png"
OnClick="DGBL_AddNewDepartment_Click" Width="16" Height="16" CssClass="VerticalAlignMiddle" AlternateText="Add a Department for selected business"
ToolTip="Add a Department for selected business" />
</Template>
</ComponentArt:GridServerTemplate>
<ComponentArt:GridServerTemplate ID="EditDepartmentTemplate1">
<Template>
<asp:ImageButton ID="imgEditDepartment" runat="server" ImageUrl="../App_Themes/OnlineForms/Images/edit.gif"
OnClick="imgEditDepartment_Click" CssClass="VerticalAlignMiddle" AlternateText="Edit selected Department"
ToolTip="Edit selected Department" />
</Template>
</ComponentArt:GridServerTemplate>
</ServerTemplates>
当两个关卡都被加载并且其中一个顶级关卡被展开以显示内部关卡并单击 addNewDepartment 时,那里有一个取消按钮。它显示一条错误消息:
未捕获的 Sys.WebForms.PageRequestManagerServerErrorException:Sys.WebForms.PageRequestManagerServerErrorException:在 System.Data.Entity.DynamicProxies.BusinessLine_29A53EE537AE4FBDCCCC328C86AED34485458642B12DFD38012946895CAB887D 类型的对象中找不到属性
BusinessLine 是作为列表提供给顶级 GridLevel 的 DataSource 的数据对象。
CS代码片段如下:
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
dgBL.PageSize = Convert.ToInt32(ConfigurationManager.AppSettings[CommonConstants.DEFAULT_PAGE_SIZE]);
dgBL.NeedDataSource += new Grid.NeedDataSourceEventHandler(dgBL_NeedDataSource);
dgBL.NeedRebind += new Grid.NeedRebindEventHandler(dgBL_NeedRebind);
dgBL.NeedChildDataSource += new Grid.NeedChildDataSourceEventHandler(dgBL_NeedChildDataSource);
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
dgBL.DataSource = GetAllBusinessLines();
dgBL.DataBind();
}
}
private void dgBL_NeedChildDataSource(object sender, GridNeedChildDataSourceEventArgs e)
{
int blID = Convert.ToInt32(e.Item["BLID"]);
UserManager um = new UserManager();
e.DataSource = um.getAllDepartments(blID);
}
protected void dgBL_NeedDataSource(object sender, EventArgs e)
{
dgBL.DataSource = GetAllBusinessLines();
}
protected void dgBL_NeedRebind(object sender, EventArgs e)
{
dgBL.DataBind();
}
protected void dgBL_PageIndexChanged(object sender, ComponentArt.Web.UI.GridPageIndexChangedEventArgs e)
{
throw new NotImplementedException();
}
protected void DGBL_AddNewDepartment_Click(object sender, EventArgs e)
{
lblAddEditDepartment.InnerText = "Add Department";
ShowControls(true);
LoadDropDowns(getCurrentBLID());
}
protected void btnCancel_Click(object sender, EventArgs e)
{
dgBL.DataSource = GetAllBusinessLines();
dgBL.DataBind();
}
任何帮助,将不胜感激。
编辑: 我刚刚找到了一个在早期版本中解决了这个问题的方法调用:
Grid1.TableCache = null; // clear out cached child data
Grid1.callback();
但它们不存在于 2012 版的组件艺术数据网格中。如果有人知道如何在 2012 版中处理此问题,我相信它会解决问题。