【发布时间】:2013-07-25 14:58:31
【问题描述】:
我需要订购我的类别标题 -
( )
按字母顺序。我该怎么做呢?谢谢!
下面是 C# 中的代码:
protected void lstvwFileCategory_OnItemDataBound(Object sender,
ListViewItemEventArgs e)
{
if (e.Item.ItemType == ListViewItemType.DataItem)
{
ListViewDataItem temp = (ListViewDataItem)e.Item;
Files.HAHADocument_Category catdata =
(Files.HAHADocument_Category)temp.DataItem;
ListView files = new ListView();
files = (ListView)e.Item.FindControl("lstvwFiles");
files.DataSource = catdata.Documents;
files.DataBind();
}
}
这是代码本身:
<asp:ListView runat="server" ID="lstvwFileCategory"
OnItemDataBound="lstvwFileCategory_OnItemDataBound">
<LayoutTemplate>
<asp:Literal runat="server" ID="itemPlaceholder" />
</LayoutTemplate>
<ItemTemplate>
<div class="linksection">
<h2><%#Eval("CategoryDescription").ToString().ToUpper()%></h2>
<asp:ListView runat="server" ID="lstvwFiles"
OnItemDataBound="lstdvwFiles_OnItemDataBound">
<LayoutTemplate>
<asp:Literal runat="server" ID="itemPlaceholder" />
</LayoutTemplate>
</div>
</ItemTemplate>
</asp:ListView>
和
if (PageID > 0)
{
HAHA_BLL.FileRepository.Files fls = new HAHA_BLL.FileRepository.Files();
lstvwFileCategory.DataSource =
fls.GetHAHADocument_Categories((int)PageID);
lstvwFileCategory.DataBind();
}
【问题讨论】:
-
你能贴出填充
lstvwFileCategory的代码吗? -
如果我有 Apples 和 Oranges,目前它正在查看 Oranges 的 ID 为 23,Apples 的 ID 为 498。所以顺序颠倒了。我只需要它来查看第一个字母并按字母顺序排列。
标签: c# listview data-binding alphabetical