View Single Post
  #1 (permalink)  
Old February 26th, 2004, 07:49 AM
miguel.ossa miguel.ossa is offline
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.