Пример для отображения данных БД
Категория: .NET
2011-11-09 14:50:30
code: #csharp
<asp:Repeater ID="DataList1" runat="server" DataSourceID="SqlDataSource1"> <ItemTemplate> <div class="listitem"> <div class="thumbnail"> <a href='<%# "News_View.aspx?Articleid=" + Convert.ToString(Eval("ID"))%>'> <Club:ImageThumbnail ID="ImageThumbnail2" runat="server" PhotoID='<%# Eval("photo") %>' NoPhotoImg="images/news.jpg" /> </a> </div> <h3> <asp:Label ID="Label3" runat="server" Text='<%# Eval("itemdate","{0:d}") %>' /> <a href='<%# "News_View.aspx?Articleid=" + Convert.ToString(Eval("ID"))%>'> <asp:Label ID="Label4" runat="server" Text='<%# Eval("title") %>' /> </a> </h3> <p> <asp:Label ID="Label2" runat="server" Text='<%# SharedRoutines.truncate((string)Eval("description")) %>' /> <a href='<%# "News_View.aspx?Articleid=" + Convert.ToString(Eval("ID")) %>'>read more »</a> </p> <div class="clearlist"></div> </div> </ItemTemplate> </asp:Repeater>
привязка к SqlDataSource1
запрос
code: #csharp
SELECT top 5 [id], [itemdate], [title], [description], [photo] FROM [Announcements] order by itemdate desc
автор: _NuClear
Поделиться: