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 215777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:30:08+00:00 2026-05-11T18:30:08+00:00

I am declaring a SQL string that looks something similar to the following: string

  • 0

I am declaring a SQL string that looks something similar to the following:

string SQL = "SELECT Column1, Column2, Column3, Date1, Date2 FROM Somewhere";

The number of columns can vary by circumstance and the dates can be called different names such as StartDate, InterestDate and so on.

What I would like to do is bind this to an ASP.NET Repeater and create a table as below for the example above:

<table>
  <tr>
    <th>Column1</th>
    <th>Column2</th>
    <th>Column3</th>
    <th>Date1</th>
    <th>Date2</th>
  </tr>
  <tr>
    Rows of values...
  </tr>
</table>

I am fine with binding the data to a Repeater and using Eval but that is dependent on a fixed number of columns and column names. Can this be done in a programmatic way?

  • 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-11T18:30:09+00:00Added an answer on May 11, 2026 at 6:30 pm

    If you use a GridView you can set the AutoGenerate columns property to true (it is true by default) and then bind the GridView to your data.

    To make is super simple, you may want to use a SQLDataSource control.

    The asp.net site has an overview of databinding in asp.net (uses the ObjectDataSource, but the concepts is exactly the same). This page also covers some of the ways to customize the GridView.

    Update: Here is a sample of how you could handle the rowdatabound event to format the date columns (per comments on other answer). This could probably be done better, but this should get you started.

    protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        DataRowView rowView = (DataRowView)e.Row.DataItem;
    
        for (int i = 0; i < rowView.Row.ItemArray.Length; i++)
        {
            DateTime? tmpDate = rowView[i] as DateTime?;
    
            if (tmpDate.HasValue)
            {
                if (tmpDate.Value.Second > 0)
                    e.Row.Cells[i].Text = tmpDate.Value.ToShortTimeString();
                else
                    e.Row.Cells[i].Text = tmpDate.Value.ToShortDateString();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 188k
  • Answers 188k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There seem to be some confusion. "POST fields" are an… May 12, 2026 at 5:33 pm
  • Editorial Team
    Editorial Team added an answer You might have an easier time with [^...] to grab… May 12, 2026 at 5:33 pm
  • Editorial Team
    Editorial Team added an answer luvieere is right -- if you want that same "delete"… May 12, 2026 at 5:33 pm

Related Questions

c#/oop noob here. I am creating a datatable from the schema of a sql
Possible Duplicate: String vs StringBuilder I just revisited some of the books that I
I want to load a list of records given a possibly lengthy list of
I am in the process of simplifying a complicated select statement, so thought I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.