Link to home
Start Free TrialLog in
Avatar of thenthorn1010
thenthorn1010Flag for United States of America

asked on

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

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"];
		conn.Open();
		DataSet ds = new DataSet("car_receipt");
		String strSelect = "Select * From CarInfo Where Sales = '" + AutoSales + "' AND Model = '" + CarModel +"' AND Color = '" + CarColor + "';
		
		try
		{
		        OracleDataAdapter DA = new OracleDataAdapter(strSelect, conn);
		        ds.Tables.Add("car_receipt");
		        DA.Fill(ds.Tables["car_receipt"]);
...

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of madgino
madgino
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial