Repeater Controls are very basic as are Most Controls. But writing your own output display is really very simple too. I have this which uses a Placeholder. Then from code behind I build a string, I put that string into a Literal Control and then add that Literal Control to the Placeholder. This way you can do anything you want.It might look intimidating but it's really not. I simply add a css class to the table row if the day = 2. You could also use a switch statement (Select Case in VB) for 7 different days. alt1, alt2 etc...<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %><!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 runat="server"> <title>Untitled Page</title> <style type="text/css"> table{border: solid 1px #222;border-collapse: collapse;} th, td{border: solid 1px #222;} .alt{background-color: #ddd;} </style></head><body> <form id="form1" runat="server"> <div><asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder> </div> </form></body></html>
using System;using System.Text;using System.Data;using System.Configuration;using System.Collections;using System.Collections.Generic;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partial class test : System.Web.UI.Page{ protected List<DataHolder2> l; protected void Page_Load(object sender, EventArgs e) { l = LoadData(); StringBuilder str = new StringBuilder(); str.AppendLine("<table>"); str.AppendLine(" <tr>"); str.AppendLine(" <th>Name</th>"); str.AppendLine(" <th>Day</th>"); str.AppendLine(" </tr>"); for (Int32 x = 0; x < l.Count; x++) { if (l[x].Day == 1) str.AppendLine(" <tr>"); else str.AppendLine(" <tr class=\"alt\">"); str.Append(" <td>"); str.Append(l[x].Name); str.AppendLine("</td>"); str.Append(" <td>"); str.Append(l[x].Day); str.AppendLine("</td>"); str.AppendLine(" </tr>"); } str.AppendLine("</table>"); Literal lit1 = new Literal(); lit1.Text = str.ToString(); PlaceHolder1.Controls.Add(lit1); } private List<DataHolder2> LoadData() { l = new List<DataHolder2>(); for (Int32 x = 0; x <= 20; x++) { DataHolder2 dh = new DataHolder2(); if (x < 10) dh.Day = 1; else dh.Day = 2; dh.Name = "John"; l.Add(dh); } return l; }}public class DataHolder2{ private Int32 _day; public Int32 Day { get { return this._day; } set { this._day = value; } } private String _name; public String Name { get { return this._name; } set { this._name = value; } }}
JBelthoff• Hosts Station is a Professional Asp Hosting Provider› As far as myself... I do this for fun!