• listview或数据绑定项目符号样式详解,加datapager分页


    在博客园搜索了很久listview分页都没有找到项目符号样式的具体活数据绑定的方法,最后,还是自己试了一下,弄出来了,发布出来供朋友们参考,包括datapager的分页绑定,如有什么需要改进的地方,敬请指教。

    效果图:

    下面贴出源码给大家参考:

    HTML源码

    <asp:ListView ID="ListView1" runat="server">
                    <AlternatingItemTemplate>
                        <li style="background-color: #FFF8DC;">批示人:
                            <asp:Label ID="CHECKUSERLabel" runat="server" Text='<%# Eval("CHECKUSER") %>' />
                            <br />
                            批示时间:
                            <asp:Label ID="CHECKDATELabel" runat="server" Text='<%# Eval("CHECKDATE") %>' />
                            <br />
                            批示意见:
                            <asp:Label ID="CHECKWORDSLabel" runat="server" Text='<%# Eval("CHECKWORDS") %>' />
                            <br />
                        </li>
                    </AlternatingItemTemplate>
                    <LayoutTemplate>
                        <ul ID="itemPlaceholderContainer" runat="server"
                            style="font-family: Verdana, Arial, Helvetica, sans-serif;">
                            <li ID="itemPlaceholder" runat="server" />
                            </ul>
                            <div style="text-align: center;background-color: #CCCCCC;font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;">
                                <asp:DataPager ID="DataPager1" runat="server" PageSize="3">
                                    <Fields>
                                        <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True"
                                            ShowNextPageButton="false" ShowPreviousPageButton="true" />
                                        <asp:NumericPagerField />
                                        <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True"
                                            ShowNextPageButton="true" ShowPreviousPageButton="false" />
                                    </Fields>
                                </asp:DataPager>
                            </div>
                        </LayoutTemplate>
                        <InsertItemTemplate>
                            <li style="">批示人:
                                <asp:TextBox ID="CHECKUSERTextBox" runat="server"
                                    Text='<%# Bind("CHECKUSER") %>' />
                                <br />
                                批示时间:
                                <asp:TextBox ID="CHECKDATETextBox" runat="server"
                                    Text='<%# Bind("CHECKDATE") %>' />
                                <br />
                                批示意见:
                                <asp:TextBox ID="CHECKWORDSTextBox" runat="server" Text='<%# Bind("CHECKWORDS") %>' />
                                <br />
                                <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="插入" />
                                <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="清除" />
                            </li>
                        </InsertItemTemplate>
                        <SelectedItemTemplate>
                            <li style="background-color: #008A8C;font-weight: bold;color: #FFFFFF;">批示人:
                                <asp:Label ID="CHECKUSERLabel" runat="server" Text='<%# Eval("CHECKUSER") %>' />
                                <br />
                                批示时间:
                                <asp:Label ID="CHECKDATELabel" runat="server" Text='<%# Eval("CHECKDATE") %>' />
                                <br />
                                批示意见:
                                <asp:Label ID="CHECKWORDSLabel" runat="server" Text='<%# Eval("CHECKWORDS") %>' />
                                <br />
                            </li>
                        </SelectedItemTemplate>
                        <EmptyDataTemplate>
                            还没有批示意见。
                        </EmptyDataTemplate>
                        <EditItemTemplate>
                            <li style="background-color: #008A8C;color: #FFFFFF;">批示人:
                                <asp:TextBox ID="CHECKUSERTextBox" runat="server"
                                    Text='<%# Bind("CHECKUSER") %>' />
                                <br />
                                批示时间:
                                <asp:TextBox ID="CHECKDATETextBox" runat="server"
                                    Text='<%# Bind("CHECKDATE") %>' />
                                <br />
                                批示意见:
                                <asp:TextBox ID="CHECKWORDSTextBox" runat="server" Text='<%# Bind("CHECKWORDS") %>' />
                                <br />
                                <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="更新" />
                                <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="取消" />
                            </li>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <li style="background-color: #DCDCDC;color: #000000;">批示人:
                                <asp:Label ID="CHECKUSERLabel" runat="server" Text='<%# Eval("CHECKUSER") %>' />
                                <br />
                                批示时间:
                                <asp:Label ID="CHECKDATELabel" runat="server" Text='<%# Eval("CHECKDATE") %>' />
                                <br />
                                批示意见:
                                <asp:Label ID="CHECKWORDSLabel" runat="server" Text='<%# Eval("CHECKWORDS") %>' />
                                <br />
                            </li>
                        </ItemTemplate>
                        <ItemSeparatorTemplate>
                            <br />
                        </ItemSeparatorTemplate>
                    </asp:ListView>

    至于C#源码,就是和repeater、gridview一样的数据绑定方法,只用把数据绑定写在protected void Page_PreRender(object sender, EventArgs e)事件里面就可以了,很简单,listview和datapager很方便。

  • 相关阅读:
    程序多开原理记录
    BitTorrent协议规范(BitTorrent Protocol Specification)之Tracker HTTP/HTTPS Protocol第三部分
    到底什么是RBD?
    关于missing unit proxies.pas
    教你简单去除 Office 2007 盗版提示
    手把手教你使用WINDBG KO XXXX游戏驱动保护
    c# 模拟提交有附件表单(转)
    常用断点(OD中)
    delphi中Webbrowser
    PS3简易蓝光规格视频制作说明
  • 原文地址:https://www.cnblogs.com/alonghay/p/fewfgew.html
Copyright © 2020-2023  润新知