Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 13th, 2006, 04:38 AM
Registered User
 
Join Date: Aug 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to bilal589
Default Literal Control

I am using ASP.net ,C#
I have a table "MAINTABLE" i m retiieving some fields from table i am using ODbc .
I want to display those fields in tables .I am using datareader .
i want to show them fields in table ( for every row generate a new table )
name :
Father NAme :
Adress
Phone NUmber

Can any one help me out .
?
Thanks in Advance.

 
Old August 14th, 2006, 06:48 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

hmmm, why not just bind the entire result set to a datagrid?? You could do something like this:

private void someMethod(){
string sqlcmd = "SELECT [data] FROM [table]";
DataTable dt = new DataTable();
dt = getDataTable();
datagrid.DataSource = dt;
datagrid.DataBind();
}

        private DataTable getDataTable(string sqlcmd)
        {
            DataTable dt = new DataTable();
            sqlConn = new SqlConnection([connection string]);
            cmd = new SqlCommand(sqlcmd, sqlConn);
            daSql = new SqlDataAdapter(sqlcmd, sqlConn);
            daSql.Fill(dt);

            return dt;
        }

where daSql = DataAdapter
cmd = SqlCommand
sqlConn = SqlConnection

hth

"The one language all programmers understand is profanity."
 
Old August 15th, 2006, 04:45 AM
Registered User
 
Join Date: Aug 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to bilal589
Default

Thanks.
         I willl try this.

 
Old August 17th, 2006, 05:17 AM
Registered User
 
Join Date: Aug 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to bilal589
Default

IT is working but not meet to my requirements i want each result set in a seperate table

 
Old August 17th, 2006, 07:11 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

What you can do is create a table in code for each row returned to the datatable something like this:

foreach(DataRow dr in dt.Rows){
   Table tbl = new Table();
   TableRow tr = new TableRow();
   TableCell tc = new TableCell();

   /*you can add styles to the rows/cells/table by calling
    *the various properties of any of the objects
    */

   tr.cells.add(tc);
   tbl.rows.add(tr);
   pnlTable.Controls.Add(tbl);
}

This assumes that there is a panel on your webform named pnlTable and you will actually have to set up the data that goes into the tables but this will give you a table for each record.

"The one language all programmers understand is profanity."
 
Old August 19th, 2006, 01:42 PM
Registered User
 
Join Date: Aug 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to bilal589
Default

thanks for reply. iwill check it out.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Label vs Literal pinch BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 October 9th, 2007 01:01 PM
What's the use of braces in a string literal? aaaa0441 Pro PHP 7 January 20th, 2007 04:23 AM
What's the use of braces in a string literal? aaaa0441 Beginning PHP 4 January 14th, 2007 08:10 AM
Using right() to return a literal value Somed00d Access 4 February 8th, 2006 02:56 PM
Object literal syntax shortt Javascript 4 May 28th, 2005 07:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.