- ItemTemplate
- AlternatingItemTemplate
- SeparatorTemplate
- HeaderTemplate
- FooterTemplate
Coding at Client Side:
<--asp:Repeater ID="Repeater1" runat="server">
<--HeaderTemplate>
<--div><--/div>
<--/HeaderTemplate>
<--ItemTemplate>
<--div>
<--a href="Profile.aspx?name=<%#Eval("Associate_Name")%>">
<--%#DataBinder.Eval(Container.DataItem, "Associate_Name")%>
<--/a>
<--/div>
<--/ItemTemplate>
<--AlternatingItemTemplate>
<--div>
<--a href="Profile.aspx?name=<%#Eval("Associate_Name")%>">
<--%#DataBinder.Eval(Container.DataItem, "Associate_Name")%>
<--/a>
<--/div>
<--/AlternatingItemTemplate>
<--FooterTemplate>
<--div><--/div>
<--/FooterTemplate>
<--/asp:Repeater>
Coding at Server Side:
protected void Page_Load(object sender, EventArgs e)
{
try
{
if(!IsPostBack)
{
DataSet ds = new DataSet();
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=klcpc292\SQLEXPRESS;" + @"Initial Catalog=FacePage; Integrated Security=SSPI;";
con.Open();
string query = "select Associate_Name from Associate_Profile where Associate_Role='Buddy'";
SqlDataAdapter adap = new SqlDataAdapter(query,con);
adap.Fill(ds);
Repeater1.DataSource = ds.Tables[0].DefaultView;
Repeater1.DataBind();
}
}
catch(Exception ex)
{
Response.Write(ex.Message);
}
}
No comments:
Post a Comment