Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6474031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:32:17+00:00 2026-05-25T06:32:17+00:00

I am using ASP.NET repeater function. Its working fine. But here all the comments

  • 0

I am using ASP.NET repeater function. Its working fine. But here all the comments are coming one by one without any separation. I need each comment to be placed in a separate box and to add back ground color to that box. Just like in wordpress comment page how the comments are separated. My complete code follows please tell me how to separate each comment.

comments.aspx

<html>
<body>
<form id="form1" runat="server">
<asp:Repeater id="Repeater1" runat="server" >
<HeaderTemplate>
<table border=1>
</HeaderTemplate>
<ItemTemplate>
<tr>
 <%# DataBinder.Eval(Container.DataItem, "Name") %> </br>
 <%# DataBinder.Eval(Container.DataItem, "Val4") %> </br></br></br>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>

        <br />
        <br />
        Name*:
        <asp:TextBox ID="tb_name" runat="server" placeholder="Your Name"></asp:TextBox>
        <br />
        <br />
        Email*:
        <asp:TextBox ID="tb_email" runat="server"></asp:TextBox>
        <br />
        <br />
        Website :
        <asp:TextBox ID="tb_website" runat="server"></asp:TextBox>
        <br />
        <br />
        <asp:TextBox ID="tb_comment" runat="server" Height="114px" TextMode="MultiLine" 
            Width="322px"></asp:TextBox>
        <br />
        <br />
        <br />
        <asp:CheckBox ID="cb_notify" runat="server" 
            Text="Notify me of followup comments via e-mail." />
        <br />
        <br />
        <br />
        <asp:Button ID="Submit" runat="server" onclick="Submit_Click" 
            Text="Post Comment" />
</form>
</body>
</html>

comments.aspx.cs

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Odbc;
using System.Collections;

public partial class comment : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        string MyConString = "DRIVER={MySQL ODBC 3.51 Driver};" + "SERVER=localhost;" + "DATABASE=softmail;" + "UID=root;" + "PASSWORD=********;" + "OPTION=3";
        OdbcConnection MyConnection = new OdbcConnection(MyConString);

        MyConnection.Open();
        OdbcCommand cmd = new OdbcCommand("Select name, email, website, comments from awm_comments", MyConnection);
        OdbcDataReader dr = cmd.ExecuteReader();
        if (dr.HasRows == false)
        {
            throw new Exception();
        }
        ArrayList values = new ArrayList();
        while (dr.Read())
        {
            if (!IsPostBack)
            {
                string a = dr[0].ToString();
                string b = dr[1].ToString();
                string c = dr[2].ToString();
                string d = dr[3].ToString();

                values.Add(new PositionData(a, b, c, d));

                Repeater1.DataSource = values;
                Repeater1.DataBind();

            }
        }
    }
    protected void Submit_Click(object sender, EventArgs e)
    {
        string name = tb_name.Text;
        string email = tb_email.Text;
        string website = tb_website.Text;
        string comment = tb_comment.Text;

        string MyConString = "DRIVER={MySQL ODBC 3.51 Driver};" + "SERVER=localhost;" + "DATABASE=softmail;" + "UID=root;" + "PASSWORD=******;" + "OPTION=3";
        OdbcConnection MyConnection = new OdbcConnection(MyConString);
        OdbcCommand cmd = new OdbcCommand("INSERT INTO awm_comments(name, email, website, comments, notify)VALUES(?, ?, ?, ?, ?)", MyConnection);
        cmd.Parameters.Add("@email", OdbcType.VarChar, 255).Value = name;
        cmd.Parameters.Add("@alternate_email", OdbcType.VarChar, 255).Value = email;
        cmd.Parameters.Add("@ipaddr", OdbcType.VarChar, 255).Value = website;
        cmd.Parameters.Add("@security_question", OdbcType.VarChar, 255).Value = comment;
        if (cb_notify.Checked == true)
        {
            int not = 1;
            cmd.Parameters.Add("@security_question", OdbcType.Int, 11).Value = not;
        }
        else if (cb_notify.Checked == false)
        {
            int not = 0;
            cmd.Parameters.Add("@security_question", OdbcType.Int, 11).Value = not;
        }
        MyConnection.Open();
        cmd.ExecuteNonQuery();
        MyConnection.Close();
        Response.Redirect("comment.aspx");
    }
    public class PositionData
    {
        private string name;
        private string ticker;
        private string val3;
        private string val4;

        public PositionData(string name, string ticker, string val3, string val4)
        {
            this.name = name;
            this.ticker = ticker;
            this.val3 = val3;
            this.val4 = val4;
        }

        public string Name
        {
            get
            {
                return name;
            }
        }

        public string Ticker
        {
            get
            {
                return ticker;
            }
        }
        public string Val3
        {
            get
            {
                return val3;
            }
        }
        public string Val4
        {
            get
            {
                return val4;
            }
        }
    }
}

Output

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:32:18+00:00Added an answer on May 25, 2026 at 6:32 am

    I would make such a thing like this

    <ItemTemplate>
        <div style="padding: 10px; margin: 5px; border: 1px dotted black; background: yellow;">
            <%# DataBinder.Eval(Container.DataItem, "Name") %> </br>
            <%# DataBinder.Eval(Container.DataItem, "Val4") %>
        </div>
    </ItemTemplate>
    

    With this approach you can leave Footer and Header tempaltes.
    Style div as you like.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an ASP.NET website where I am using an asp:repeater with paging
I am using Repeater Control in ASP.Net. But i get a lot of errors
I am using Repeater Control in ASP.Net. But i get a lot of errors
I have been using ASP.NET for years, but I can never remember when using
When I'm working with DataBound controls in ASP.NET 2.0 such as a Repeater, I
I am using ASP.NET repeater and I want to display No Row Found message
I'm using an ASP.NET Repeater control to create rows of textboxes. I'm able to
I am using ASP.NET and C#. All of the pie chart controls that I
I am trying to bind Asp.Net Repeater Control for Ajax Data using DataTables Plugin
In my asp.net website I am using nested repeaters.Outer repeater is used to display

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.