asp.net gridview 和 repeater 模板代码示例

Repeater

复制代码
                    <asp:Repeater ID="rpt_Video" runat="server" OnItemCommand="rpt_Video_ItemCommand">
<HeaderTemplate>
<table border="0" cellspacing="1" cellpadding="1" class="TableRepeater">
<tr class="RepeaterHeadCss">
<th width="130px">
字段1
</th>
<th width="150px">
字段2
</th>
<th width="80px">
字段3
</th>
<th width="80px">
字段4
</th>
<th width="80px">
字段5
</th>
<th width="80px">
字段6
</th>
<th colspan="140">
字段7
</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr class="RepeaterItemCss">
<td>
<%#Eval("字段1")%>
</td>
<td>
<%#Eval("字段2")%>
</td>
<td>
<%#Eval("字段3")%>
</td>
<td>
<%#Eval("字段4")%>
</td>
<td>
<%#Eval("字段5")%>
</td>
<td>
<%#Eval("字段6")%>
</td>
<td width="4%">
<%#Eval("字段7")%>
</td>
<td width="4%">
<%#Eval("字段7")%>
</td>
<td width="4%">
<%#Eval("字段8")%>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
复制代码

GridView

复制代码
                <asp:GridView ID="gvD_Order" runat="server" Width="100%" IsShowSingleSelectColumn="true"
BorderStyle
="None" AllowPaging="true" IsShowFooterToolbar="True" IsShowHeaderToolbar="true"
IsSinglePageDataMode
="False" IsDoubleClickSelectOneLine="true" PageSize="15"
OnRowDataBound
="gvD_Order_RowDataBound" IsTriggerSelect="true" IsHideCheckBoxColumn="false"
SingleSelectColumnValueFiled
="ID" IsAutoSetHorizontalAlign="false" OnRowCommand="gvD_Order_RowCommand">
<Columns>
<asp:TemplateField HeaderText="字段1">
<ItemStyle HorizontalAlign="Center" Width="200px" />
<ItemTemplate>
<%#Eval("字段1")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="字段2">
<ItemStyle HorizontalAlign="Center" Width="120px" />
<ItemTemplate>
<%#Eval("字段2")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="字段3">
<ItemStyle HorizontalAlign="Center" Width="120px" />
<ItemTemplate>
<%#Eval("字段3")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="字段4">
<ItemStyle HorizontalAlign="Right" Width="100px" />
<ItemTemplate>
<%#Eval("字段4", "{0:0.######}")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="字段5">
<ItemStyle HorizontalAlign="Center" Width="120px" />
<ItemTemplate>
<%#Eval("字段5","{0:yyyy-MM-dd HH:mm:ss}")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="字段6">
<ItemStyle Width="120px" HorizontalAlign="Center" />
<ItemTemplate>
<asp:Label ID="字段6" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="操作">
<ItemStyle HorizontalAlign="Center" Width="70px" />
<ItemTemplate>
<asp:LinkButton ID="lbEdit" CommandName="EditView" runat="server" CausesValidation="false"
CommandArgument
='<%#Eval("ID")%>'>查看详细</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle BackColor="White" Font-Bold="True" Font-Size="9pt" VerticalAlign="Middle"
Wrap
="True" />
<PagerStyle VerticalAlign="Top" />
<AlternatingRowStyle VerticalAlign="Top" />
</asp:GridView>
复制代码




本文作者:拓荒者IT

本文链接:https://www.cnblogs.com/youring2/archive/2011/10/09/2203340.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

 

📌做了个微信公众号【拓荒者IT】,分享各种技术干货,新内容首发到公众号,欢迎关注❤️

posted @   拓荒者IT  阅读(1133)  评论(0编辑  收藏  举报
皮肤配置 参考地址:https://www.yuque.com/awescnb/user
点击右上角即可分享
微信分享提示
💬
评论
📌
收藏
💗
关注
👍
推荐
🚀
回顶
收起