ASPX PAGE CODE:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="repeater-alternateitem.aspx.cs" Inherits="repeater_alternateitem" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style>
table, tr,th,td{
border:1px solid black;
}
th{
font-size:20px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Repeater ID="rptMembers" runat="server">
<HeaderTemplate>
<table>
<tr>
<th>
FULLNAME
</th>
<th>
CITY
</th>
<th>
PHONE NO.
</th>
<th>
EMAIL ID
</th>
<th>
WEB SITE
</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr style="background-color:lightpink">
<td>
<%# Eval("FullName") %>
</td>
<td>
<%# Eval("City") %>
</td>
<td>
<%# Eval("PhoneNumber") %>
</td>
<td>
<%# Eval("EmailID") %>
</td>
<td>
<%# Eval("WebSite") %>
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr style="background-color:lightblue">
<td>
<%# Eval("FullName") %>
</td>
<td>
<%# Eval("City") %>
</td>
<td>
<%# Eval("PhoneNumber") %>
</td>
<td>
<%# Eval("EmailID") %>
</td>
<td>
<%# Eval("WebSite") %>
</td>
</tr>
</AlternatingItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</div>
</form>
</body>
</html>
ASPX.CS file CODE BEHIND CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class rpeater_accordian : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
FriendDataClassesDataContext db = new FriendDataClassesDataContext();
var MemList = (from a in db.dbMembers select a).ToList();
rptAccord.DataSource = MemList;
rptAccord.DataBind();
}
}
No comments:
Post a Comment