嵌套字典到嵌套转发器asp.net c#
发布时间:2020-05-24 11:42:34 所属栏目:asp.Net 来源:互联网
导读:我正在制作一个asp.page,它将显示有关公司资产的分层信息. 为了获取数据,我使用了lambda表达式: FASAssetInfoDataContext fasInfo = new FASAssetInfoDataContext(); var data = from g in fasInfo.Asset_Informations
|
我正在制作一个asp.page,它将显示有关公司资产的分层信息. 为了获取数据,我使用了lambda表达式: FASAssetInfoDataContext fasInfo = new FASAssetInfoDataContext();
var data = from g in fasInfo.Asset_Informations
where g.Department.Substring(0,3) == p
select g;
Dictionary<string,Dictionary<string,List<info>>> branch = data.GroupBy(e => e.Location)
.ToDictionary(g => g.Key,g => g.GroupBy(gl => gl.G_L_Asset_Acct_No)
.ToDictionary(gl => gl.Key,gl => gl.Select(s => new info
{
acqDate = s.Acquisition_Date,asstNo = s.Co_Asset_Number,classInfo = s.Class,description = s.Description,mfgSerialNo = s.Mfg_Serial_No,deprThisRun = s.Depr_This_Run__Int_,AcqValue = s.Acquisition_Value__Int_,currentAccDepr = s.Current_Accum_Depr__Int_,estLife = s.Est_Life__YYMM___Int_,inServiceDate = s.Placed_In_Service_Date__Int_,netBookValue = s.Current_Net_Book_Value__Int_,oldAcqValue = s.Acquisition_Value__Tax_
}).ToList()));
所以我现在有一组嵌套的字典,最后有一个信息列表.我的问题是如何在页面本身上最好地显示这些信息?我可以获得第一级,但一直在努力让嵌套的中继器正常运行.如果有更好的控制使用我都是耳朵:) 谢谢, 马尔科 解决方法如果你确实需要使用嵌套的中继器,那么它可能,但是让它工作并不是特别明显.以下方法可行(简化为简洁):<asp:Repeater id="level1" OnItemDataBound="level1_ItemDataBound" ...>
<ItemTemplate>
<asp:Repeater id="level2" OnItemDataBound="level2_ItemDataBound" ...>
<ItemTemplate>
<asp:Repeater id="level3" OnItemDataBound="level3_ItemDataBound" ...>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
代码背后: protected void Page_Load(object sender,EventArgs e)
{
Dictionary<string,List<info>>> branch = ...;
level1.DataSource = branch;
level1.DataBind();
}
protected void level1_ItemDataBound(object sender,RepeaterItemEventArgs e)
{
Dictionary<string,List<info>> data = (Dictionary<string,List<info>>)e.Item.DataItem;
Repeater level2 = e.Item.FindControl("level2") as Repeater;
level2.DataSource = data;
level2.DataBind();
}
protected void level2_ItemDataBound(object sender,RepeaterItemEventArgs e)
{
List<info> data = (List<info>)e.Item.DataItem;
Repeater level3 = e.Item.FindControl("level3") as Repeater;
level3.DataSource = data;
level3.DataBind();
}
protected void level3_ItemDataBound(object sender,RepeaterItemEventArgs e)
{
// Bind properties from info elements in List<info> here
} (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – 使用asp.net属性路由的根路径的默认路由
- asp.net – 只能将一个ScriptManager实例添加到页面中
- asp.net-mvc – asp.net mvc wiki
- asp.net-web-api2 – 如何创建HttpRequestHeaders类的实例
- 将数据从ASP.net返回到ExtJS网格
- asp.net-mvc – 在一个页面中以两种不同的形式使用多个@ Ht
- asp.net – visual studio 2017调试无法启动程序无效指针
- asp.net-mvc – 在ASP.NET MVC项目中访问elmah.axd时出现“
- asp.net-mvc-3 – 有没有办法使用@ Html.HiddenFor获取完整
- asp.net-mvc – 如何根据用户过滤MVC 4中的结果
推荐文章
站长推荐
- asp.net-mvc – ASP.NET MVC3中的随机会话超时
- asp.net – 您有任何免费的.Net托管代码将DocX转
- asp.net – 如何使用带有TemplateFields的Object
- asp.net – 一个明智的PasswordStrengthRegularE
- 选择完成后和提交上传之前的asp.net FileUpload事
- 用于访问Gravatar图像的ASP.NET MVC帮助器
- asp.net – 如何在转发器中每行显示x个项目?
- asp.net – 如何在Ember.js应用程序中使用ASP .N
- asp.net-core – 将绝对文件路径转换为相对路径
- asp.net – 如何使用CSS垂直向下移动div
热点阅读
