objectlist拆分_如何在ASP.NET Mobile ObjectList中显示多个列

objectlist拆分

objectlist拆分

When using ASP.NET Mobile Controls to display a list of information, you'll usually use an ObjectList and databinding. ObjectList is a great control with lousy documentation.

使用ASP.NET移动控件显示信息列表时,通常将使用ObjectList和数据绑定。 ObjectList是一个糟糕的文档的很好的控件。

When you turn off AutoGenerateFields and bind a collection of objects to the list - as I'm in banking, my example is always "Accounts" - you need to give a list of Fields that you want to bind to.

当您关闭AutoGenerateFields并将对象集合绑定到列表时(例如我在银行业时,我的示例始终是“帐户”),您需要提供要绑定到的字段列表。

<mobile:ObjectList
        ID="listAccounts"
        Runat="server" 
        AutoGenerateFields="False" TableFields="Description;AvailableBalance">
    <Command Name="AccountHistory" Text="Account History" />
    <Command Name="Transfer" Text="Make a Transfer" />        <Field DataField="Description" Name="Description" Title="Account" />
        <Field DataField="NumberMasked" Name="NumberMasked" Title="Number" />
        <Field DataField="AvailableBalance" DataFormatString="${0:0,0.00}" Name="AvailableBalance"
            Title="Balance" />
        <Field DataField="Index" Name="Index" Visible="False" />

</mobile:ObjectList>

<mobile:ObjectList ID =“ listAccounts” Runat =“服务器” AutoGenerateFields =“ False” TableFields =“ Description; AvailableBalance” > <命令名称=“ AccountHistory”文本=“帐户历史” /> <命令名称=“传输”文本=“进行传输” /> <Field DataField =“ Description” Name =“ Description” Title =“ Account” /> <Field DataField =“ NumberMasked” Name =“ NumberMasked” Title =“ Number” /> <Field DataField =“ AvailableBalance” DataFormatString =“ $ {0:0,0.00}” Name =“ AvailableBalance” 标题=“余额” /> <Field DataField =“ Index” Name =“ Index” Visible =“ False” /> </ mobile:ObjectList>

Here's the icky part. By default the list will only show the FIRST field - in my case "Description" - in the list. It'll be hyperlinked to a subform that will show the rest of the fields. Remember, we're designing for mobile here.

这是棘手的部分。 默认情况下,列表仅在列表中显示FIRST字段-在我的情况下为“ Description”。 它将超链接到一个子表单,该子表单将显示其余字段。 记住,我们正在为移动设备而设计。

The useful little-known/documented trick is that if you put a semicolon separated list of DateFields in the TableFields attribute you'll get multiple columns when the ObjectList first displays.

有用的鲜为人知/已记录的技巧是,如果在TableFields属性中放入以分号分隔的DateFields列表,则在ObjectList首次显示时会得到多列

One other unrelated note. For some reason when I use DataFormatString="C" to format the decimal AvailableBalance as a Currency, I get a string star-like character. Perhaps something wrong with the current UI culture. I worked/hacked around it with a format string like DataFormatString="${0:0,0.00}" for now.

另一无关的注释。 由于某些原因,当我使用DataFormatString =“ C”将十进制的AvailableBalance格式化为Currency时,我得到了一个字符串,类似于星形字符。 当前的UI文化可能有问题。 我现在使用/使用DataFormatString =“ $ {0:0,0.00}”这样的格式字符串来解决它。

翻译自: https://www.hanselman.com/blog/how-to-show-multiple-columns-in-an-aspnet-mobile-objectlist

objectlist拆分

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值