How to Dynamically Build a Table in ASP.NET Using C#/ASP.NET From Database Search Results

Posted on 2011-10-11
Medium Priority
Last Modified: 2013-12-16
I have successfully queried a database, and I am at the point of displaying the results of a query that is run on a web page called Results.ASPX. I am new to ASP.NET, and I was attempting to figure out the syntax to dynamically build the ASPX page from within the C#/ASP.NET code. (I have attached a snippet of code that is being used in order to build the query and is called upon the RESULTS.ASPX page being loaded.) Could someone help me with the syntax that I would need in order to have the results displayed in a table with each column, or attribute, from the query being a new column in the table and each record being a new row.

Any help is greatly appreciated.
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace Research
    public partial class Results : System.Web.UI.Page
        String AutoSales;
        String CarModel;
        String CarColor;

        protected void Page_Load(object sender, EventArgs e)
		AutoSales = Request.QueryString["Sales"];
		CarModel = Request.QueryString["Model"];
		CarColor = Request.QueryString["Color"];
		OracleConnection conn = new OracleConnection();
		conn.ConnectionString = WebConfigurationManager.AppSettings["CarConnection"];
		DataSet ds = new DataSet("car_receipt");
		String strSelect = "Select * From CarInfo Where Sales = '" + AutoSales + "' AND Model = '" + CarModel +"' AND Color = '" + CarColor + "';
		        OracleDataAdapter DA = new OracleDataAdapter(strSelect, conn);

Open in new window

Question by:thenthorn1010
  • 2
LVL 11

Accepted Solution

madgino earned 2000 total points
ID: 36951659
you add a gridview on the page and bind it to the dataset:

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month13 days, 20 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question