博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
2012年4月19日
阅读量:7085 次
发布时间:2019-06-28

本文共 1597 字,大约阅读时间需要 5 分钟。

Datalist


<asp:DataList ID="DlBranch" BorderColor="black" CellPadding="5" CellSpacing="5" RepeatDirection="Vertical"

RepeatLayout="Table" RepeatColumns="3" runat="server">


BorderColor:背景颜色。 CellPadding:单元格边距。CellSpacing:单元格间距。RepeatDirection:用于设置或返回包含的项目垂直显示还是水平显示。

  • Horizontal - 项目水平显示
  • Vertical - 默认。项目垂直显示。
  • RepeatLayout:属性用于设置或获取如何显示在包含中的项目。

  • Flow - 项目不显示在表格中
  • Table - 默认。项目显示在表格中
  • RepeatColumns :属性用于设置或返回当显示复显示项目时所使用的列数。


     <a href="DBranch_Show.aspx?BranchID=<%#DataBinder.Eval(Container.DataItem,"BranchID") %>">

                    <%#DataBinder.Eval(Container.DataItem, "BranchName") %></a>


    Container即容器,指父控件;

    DataItem指父控件所绑定的数据源的当前行,不是字段。

    如果只是显示值<%#("字段名")%>就可以了.如果是要修改值<%#Bind("字段名")%>就可以了.


    <%# DataBinder.(Container.DataItem, "IntegerValue", "{0:c}") %>
    <%# DataBinder.(Container.DataItem, "Discontinued", "{0:G}") %>;0G代表True,flase;

    <%#Container.DataItem("price","{0:¥#,##0.00}")%>

    <%# DataBinder.(Container.DataItem,"Company_Ureg_Date","{0:yyyy-M-d}")%>


      <HeaderTemplate>

    <ItemTemplate>


     <table>

            <tr>
                <asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">
                    <ItemTemplate>
                        <td>
                            <ul>
                                <li style="list-style: none; float: left;"><a href="DBranch_Show.aspx?BranchID=<%#DataBinder.Eval(Container.DataItem,"BranchID") %>">
                                    <%#DataBinder.Eval(Container.DataItem, "BranchName") %></a> </li>
                            </ul>
                        </td>
                    </ItemTemplate>
                </asp:Repeater>
            </tr>
        </table>


    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)

        {
            if (i % 3 == 0 && i > 0)
            {
                e.Item.Controls.Add(new LiteralControl("</tr><tr>"));
            }
            i++;
        }


     

转载于:https://www.cnblogs.com/W-Scarecrow/archive/2012/04/19/2457479.html

你可能感兴趣的文章
read和变量设定方式
查看>>
Winmail + Rsync + Nmap 实现 Winmail 邮件系统双机热备
查看>>
python读写文件
查看>>
1-4常用路由协议的梳理
查看>>
Javascript核心
查看>>
利用UltraISO制作RedhatU盘启动盘
查看>>
一分钟教你快速建立起MySQL/Mariadb 主从状态检测脚本(shell)
查看>>
hive函数 -- regexp_extract
查看>>
C# vs2010 调用webservice
查看>>
Samba用户管理机制
查看>>
解决securecrt连接centos使用VIM编辑中文时乱码
查看>>
Windows server 2008R2域的安装和访问
查看>>
spring boot简单实现rest服务
查看>>
linux内核编译安装
查看>>
在CentOS/RHEL/Scientific Linux 6 & 7 上安装Telnet
查看>>
linux中hash命令:显示、添加或清除哈希表
查看>>
理解MySQL复制(Replication)——经典文献
查看>>
安卓手机recovery下刷补丁提示:“can't open /sdcard/update.zip(bad)”
查看>>
shared_ptr源码分析
查看>>
AOJ 2164 Revenge of the Round Table 题解《挑战程序设计竞赛》
查看>>