项目模板和布局模板有什么区别。在布局模板中只有我们有有关设计的信息?或任何其他东西。我无法理解项目模板..请解释一下..!
除了这个之外,我还在这样的项目中查询
SELECT TOP (1) ProductName, UnitPrice FROM Products ORDER BY NEWID()
这里NEWID()是什么意思?是与sqlserver相关的预定义函数吗?我的项目中没有下载任何 newid() 函数。如果它是预定义函数那么它能做什么?
谢谢
最佳答案
ListView 控件的主布局是通过定义 LayoutTemplate 创建的。 LayoutTemplate 将包含充当数据占位符的控件,例如表、面板、标签或 HTML 控件(例如 runat 属性设置为“server”的 table、div 或 span 元素)。 项目模板是主模板,它将以重复的方式显示绑定(bind)到 ListView 的数据。此模板通常包含数据绑定(bind)到数据列或其他单独数据元素的控件。这两个模板是必需的。
GroupTemplate 将用于对项目进行分组。 EditItemtemplate、SelectedItemTemplate、InsertItemTemplate 显示在特定操作(如插入、编辑、选择)中。 ItemSeparatorTemplate、GroupSeparatorTemplate 用于分别分隔单个项目和组项目。
这里有区别ItemPlaceholderID="itemPlaceholder"
<asp:ListView runat="server" ID="ListView1" ItemPlaceholderID="itemPlaceholder">
<LayoutTemplate>
<table border="0" cellpadding="1">
<tr style="background-color:#E5E5FE">
<th align="left"><asp:LinkButton ID="lnkId" runat="server">Id</asp:LinkButton></th>
<th align="left"><asp:LinkButton ID="lnkName" runat="server">Name</asp:LinkButton></th>
<th align="left"><asp:LinkButton ID="lnkType" runat="server">Type</asp:LinkButton></th>
<th></th>
</tr>
<tr id="itemPlaceholder" runat="server"></tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td><asp:Label runat="server" ID="lblId"><%#Eval("ID") %></asp:Label></td>
<td><asp:Label runat="server" ID="lblName"><%#Eval("FirstName")+"
"+Eval("LastName") %></asp:Label></td>
<td><asp:Label runat="server" ID="lblType"><%#Eval("Type") %></asp:Label></td>
<td></td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr style="background-color:#EFEFEF">
<td><asp:Label runat="server" ID="lblId"><%#Eval("ID") %></asp:Label></td>
<td><asp:Label runat="server" ID="lblName"><%#Eval("FirstName")+" "+
Eval("LastName") %></asp:Label></td>
<td><asp:Label runat="server" ID="lblType"><%#Eval("Type") %></asp:Label></td>
<td></td>
</tr>
</AlternatingItemTemplate>
</asp:ListView>
关于asp.net - 项目模板和布局模板之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4955512/