asp.Netgridviewとrepeaterテンプレートコードの例

32484 ワード

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>