Net-informations.com
SiteMap  | About    

How to Repeater

The ASP.NET Repeater is a basic container control that allows you to create custom lists from any data available to the page. It provides a highly customizable interface. It has no built-in layout or styles, so you must explicitly declare all layout, formatting, and style tags within the controls templates. Every Repeater control requires minimum an ItemTemplate.

  

<asp:Repeater id="repeater1" runat="server" >
<ItemTemplate>
	<%# DataBinder.Eval(Container.DataItem, "stor_id")%>
</ItemTemplate>
</asp:Repeater>

simple-repeater

The Repeater control that render HTML to display the contents of a list or data source to which they are bound. If the Repeater controls data source is set but no data is returned, the control renders with no items. If the data source is Nothing, the Repeater is not rendered. The following ASP.NET program shows how to display data using a Repeater Control.

Default.aspx

  

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
	<form id="form1" runat="server">
	<div>
		<asp:Repeater id="repeater1" runat="server" DataSourceID="SqlDataSource1">
		<ItemTemplate>
			<%# DataBinder.Eval(Container.DataItem, "stor_id")%> &nbsp;&nbsp;
			<%# DataBinder.Eval(Container.DataItem, "stor_name")%> <br />
		</ItemTemplate>
		</asp:Repeater>
		<asp:SqlDataSource ID="SqlDataSource1" runat="server"
		ConnectionString="<%$ ConnectionStrings:SQLDbConnection %>"
		SelectCommand="select [stor_id],[stor_name] from stores" />
	</div>
	</form>
</body>
</html>






net-informations.com (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.