自定义动态创建的菜单产生一些奇怪的错误
背景是我有一个自定义控件,它是链接到 xmldatasource 的 asp:Menu。 xmldatasource 是根据用户权限动态创建的。 这是自定义控件的加载事件:
protected void Page_Load(object sender, EventArgs e)
{
string userId = (string)Session["userId"];
if (userId != null)
{
DataSet ds = dal.RetrieveApplications(userId);
ds.DataSetName = "Menus";
ds.Tables[0].TableName = "Menu";
DataRelation relation = new DataRelation
("ParentChild",
ds.Tables["Menu"].Columns["Folder_Id"],
ds.Tables["Menu"].Columns["Parent_Folder_ID"], true);
relation.Nested = true;
ds.Relations.Add(relation);
xmlDataSource1.Data = ds.GetXml();
}
}
这对于第一个使用它的用户来说非常有效。 但似乎每个后续用户实际上都获得了第一个用户的菜单。 我已经完成并验证了我的数据集已正确创建,并且当我在加载结束时检查 XMLDatasource.data 时,xml 是正确的。
我真的被困住了。
The background is I have a custom control that is a asp:Menu that is linked to an xmldatasource. The xmldatasource is created dynamically depending on the user privies. Here is the load event for the custom control:
protected void Page_Load(object sender, EventArgs e)
{
string userId = (string)Session["userId"];
if (userId != null)
{
DataSet ds = dal.RetrieveApplications(userId);
ds.DataSetName = "Menus";
ds.Tables[0].TableName = "Menu";
DataRelation relation = new DataRelation
("ParentChild",
ds.Tables["Menu"].Columns["Folder_Id"],
ds.Tables["Menu"].Columns["Parent_Folder_ID"], true);
relation.Nested = true;
ds.Relations.Add(relation);
xmlDataSource1.Data = ds.GetXml();
}
}
This works perfectly for the first user that uses it. But it seems that every subsequent user is actually getting the first user's menu. I have walked it through and verified that my dataset is getting created fine and when I examine the XMLDatasource.data at the end of the load the xml is correct.
I am really stuck.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了答案,尽管我会将其留在这里供其他可能搜索此内容的人使用:
但我必须在 xmldatasource 上将“ENABLECACHING”设置为 false。
I found the answer and though I would leave it out here for others who might search for this:
But I had to set the "ENABLECACHING" to false on the xmldatasource.