是否使用“SortExpression”?在 DetailsView 的 BoundField 中有意义吗?

发布于 2024-11-11 15:23:14 字数 916 浏览 5 评论 0原文

我正在学习 M$ 证书。我使用“自定进度”培训套件(书)。我遇到了一些让我有点困惑的事情。在网上找到一些执行相同操作的代码示例后,我决定向社区询问。

这是正文:

DetailsView控件不直接支持排序,而GridView控件 做。但是,您可以使用 DataSource 控件(如第 1 课中所述)来管理数据 排序。

这是书中示例代码的一个片段:

<asp:DetailsView runat="server" Width="300px"
ID="DetailsView1"
AllowPaging="True"
AutoGenerateRows="False"
DataKeyNames="ProductID"
DataSourceID="SqlDataSource1">
<Fields>
    <asp:BoundField DataField="ProductID" HeaderText="ProductID"
        InsertVisible="False" ReadOnly="True" SortExpression="ProductID" />
    <asp:BoundField DataField="ProductName" HeaderText="ProductName"
        SortExpression="ProductName" />
    ...
    ...
    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True"
        ShowInsertButton="True" />
</Fields>
</asp:DetailsView>

问题是:这个 SortExpression 这里有什么意义吗?

I'm studying for a M$ certificate. I use the 'self-paced' Training Kit (book). I bumped into something which confuses me a bit. After finding some code samples online doing the same, I decided to ask the community.

This is the text:

The DetailsView control does not directly support sorting, whereas the GridView control
does. However, you can use the DataSource control, as discussed in Lesson 1, to manage data
sorting.

And here is a snip from the sample code in the book:

<asp:DetailsView runat="server" Width="300px"
ID="DetailsView1"
AllowPaging="True"
AutoGenerateRows="False"
DataKeyNames="ProductID"
DataSourceID="SqlDataSource1">
<Fields>
    <asp:BoundField DataField="ProductID" HeaderText="ProductID"
        InsertVisible="False" ReadOnly="True" SortExpression="ProductID" />
    <asp:BoundField DataField="ProductName" HeaderText="ProductName"
        SortExpression="ProductName" />
    ...
    ...
    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True"
        ShowInsertButton="True" />
</Fields>
</asp:DetailsView>

The question is: Does this SortExpression have any point here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

终止放荡 2024-11-18 15:23:14

GridView 和DetailsView 使用BoundField、CommandField 等,因此这对GridView 很有用,但对DetailsView 没有用。 DetailsView 的形式是单一的,因为它一次只显示一条记录,因此排序不利于公开。

HTH。

The GridView and DetailsView uses the BoundField, CommandField, etc. so this is useful for the GridView, but not for the DetailsView. DetailsView is singular in form as it only shows one record at a time so sorting wouldn't be beneficial to expose.

HTH.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文