Created
October 2, 2014 12:26
-
-
Save s0ren/bf1c02b33bf3483cb7be to your computer and use it in GitHub Desktop.
Simpel demo på repeater
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default_repeater.aspx.cs" Inherits="_Default" %> | |
<!DOCTYPE html> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head runat="server"> | |
<title></title> | |
</head> | |
<body> | |
<form id="form1" runat="server"> | |
<div> | |
<%-- | |
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display."> | |
<Columns> | |
<asp:BoundField DataField="id" HeaderText="id" SortExpression="id" /> | |
<asp:BoundField DataField="Navn" HeaderText="Navn" SortExpression="Navn" /> | |
<asp:BoundField DataField="foedt" HeaderText="foedt" SortExpression="foedt" /> | |
<asp:BoundField DataField="opstaldet_i" HeaderText="opstaldet_i" SortExpression="opstaldet_i" /> | |
</Columns> | |
</asp:GridView> | |
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DerbyConnectionString1 %>" ProviderName="<%$ ConnectionStrings:DerbyConnectionString1.ProviderName %>" SelectCommand="SELECT [id], [Navn], [foedt], [opstaldet_i] FROM [Hest]"></asp:SqlDataSource> | |
--%> | |
<asp:Repeater ID="RepeaterHeste" runat="server"> | |
<HeaderTemplate> | |
<section> | |
</HeaderTemplate> | |
<ItemTemplate> | |
<h2><%# Eval("Navn") %></h2> | |
<p>fra: <%# Eval("foedt", "{0:D}") %></p> | |
<hr /> | |
</ItemTemplate> | |
<FooterTemplate> | |
</section> | |
</FooterTemplate> | |
</asp:Repeater> | |
</div> | |
</form> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using System.Web.UI; | |
using System.Web.UI.WebControls; | |
using System.Configuration; | |
using System.Data.SqlClient; | |
using System.Data.SqlTypes; | |
public partial class _Default : System.Web.UI.Page | |
{ | |
protected void Page_Load(object sender, EventArgs e) | |
{ | |
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DerbyConnectionString1"].ToString()); | |
SqlCommand cmd = new SqlCommand(); | |
cmd.Connection = conn; | |
cmd.CommandText = "SELECT * FROM Hest"; | |
conn.Open(); | |
SqlDataReader reader = cmd.ExecuteReader(); | |
RepeaterHeste.DataSource = reader; | |
RepeaterHeste.DataBind(); | |
conn.Close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment