Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 26th, 2004, 07:49 AM
Authorized User
Join Date: Nov 2003
Location: Mataro, Barcelona, Spain.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default Show table in DataList


I want to show a table in a datalist control. I've tried but I can't see nothing in the page when I executed. What's the problem?

            DataRow[] foundRows;

            ds = new DataSet("ALMACEN");
            dt = ds.Tables.Add("PRODUCTOS");
            dt.Columns.Add("id_producto", typeof (Int32));
            dt.Columns.Add("nombre", typeof (String));
            dt.PrimaryKey = new DataColumn[] { dt.Columns["id_productos"] };
            da = new SqlDataAdapter ("SELECT * FROM materia_prima", myConnection);
            da.Fill(ds, "PRODUCTOS");
            foundRows = dt.Select();
            for (int i = 0; i < foundRows.Length; i++)
                dr = dt.NewRow();

                dr[0] = foundRows[i]["id_producto"];
                dr[1] = foundRows[i]["nombre"];


            DataView dv = new DataView(dt);
            dlProductos.DataSource = dv;
            dlProductos.DataKeyField = "id_producto";

World only exists into your mind.
  #2 (permalink)  
Old February 26th, 2004, 10:29 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

It looks to me like you have greatly over complicated this code. I don't think you need to write all that code that creates a table for the dataset. When you use the data adapter to fill the dataset, it will create the table for you. That would at least simplify things. Start with that and see where you get.

ds = new DataSet("ALMACEN");
da = new SqlDataAdapter ("SELECT id_producto, nombre FROM materia_prima", myConnection);
da.Fill(ds, "PRODUCTOS");
dlProductos.DataSource = ds.Tables[0];
dlProductos.DataKeyField = "id_producto";

Work smarter, not harder.

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to show text in datalist while value in NULL nittin14 ASP.NET 1.0 and 1.1 Basics 4 September 1st, 2007 06:28 PM
use datalist via xml to show picture in output zuz29 ASP.NET 2.0 Basics 0 May 27th, 2006 06:51 PM
How to show thumbnail in the GridView/DataList walgr2k ASP.NET 2.0 Basics 1 May 20th, 2006 10:17 AM
Show item in datalist control keyvanjan ASP.NET 1.0 and 1.1 Professional 0 January 14th, 2006 03:44 PM
Bind records from the table to a datalist control macupryk General .NET 1 October 13th, 2004 11:59 AM

All times are GMT -4. The time now is 10:52 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.