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

  • SEARCH
  • Home
  • 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 6529645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:39:37+00:00 2026-05-25T09:39:37+00:00

I coded for a comments page. Its working fine but all the SELECTED records

  • 0

I coded for a comments page. Its working fine but all the SELECTED records are being displayed using Response.Write(dr[0].ToString()); But using Response.Write we cannot manage them in orderly manner. So, I decided to display records in Labels but I am not interested to use pagination. So, now to automatically add a new Set of Labels (i.e. a set is a set of labels name, email, website and comments) on every update of records?

I also tried using Labels instead of Response.Write but in Labels only last record is being displayed.

Please tell me how to display each record in each set of labels.

My code follows.

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

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=test_com;" + "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();
            }
            while (dr.Read())
            {
                Response.Write(dr[0].ToString());
                Response.Write(dr[1].ToString());
                Response.Write(dr[2].ToString());
                Response.Write(dr[3].ToString());

                /* test using labels. Being displayed only last record. 
                Label1.Text = dr[0].ToString();
                Label2.Text = dr[1].ToString();
                Label3.Text = dr[2].ToString();
                Label4.Text = dr[3].ToString();
                */
            }
    }
    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=test_com;" + "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();
    }
}
  • 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-25T09:39:38+00:00Added an answer on May 25, 2026 at 9:39 am

    I would suggest you scratch most of what you have and use a repeater.

    Follow the following basic how to use a repeater article http://www.sitepoint.com/asp-net-repeater-control/

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

Sidebar

Related Questions

I am using ASP.NET repeater function. Its working fine. But here all the comments
Its working in Firefox but in Internet Explorer the select(dropdown) just hide from the
I am trying to implement the Facebook Like Button but its not working. In
I'm using Facebook comments Plugin on one of my page (WordPress Driven) and it
The code below prints out all comments for a given submissionid in chronological order.
I'd like to have comments in my code, but I want them to be
I'm currently working with OpenGL ES 1.1 and using the DrawElements convention along with
I am using jQuery resizable from interface.eyecon.ro/docs/resizable for a menu on a page that
Pre-abmle: I am using MakeMeeting module to create/display meeting polls. This module has its
I'm working on an open source project. The original project contains comments in russian

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.