Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Displaying a DataTable within a DataGrid cell ASP.NET

Reply
Thread Tools

Displaying a DataTable within a DataGrid cell ASP.NET

 
 
mr killer
Guest
Posts: n/a
 
      09-29-2004
I have an ASP.NET application simply displaying a DataGrid control on a form.
Within some of the DataGrid cells I display multiple records within that
cell based on an SQL query that loops through some table records.
Unfortunately I can't format those records to be on there own separate line
within the DataGrid cell, because the cell obviously just displays my results
one after the other in the same cell. What I want to do is populate a
separate DataTable, and store each record I grab in my query into its' own
row within that DataTable. Then I want to display that DataTable within a
specified DataGrid cell so the data will look stacked within the cell. This
stems of the fact that HTML developers use tables for positioning data on a
web-form, so I want to see if I can do the same thing within an ASP.NET
DataGrid control. Is this possible? Thanks.


 
Reply With Quote
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      09-30-2004
You might want to see whether the free HierarGrid control will help you
there:

http://www.denisbauer.com/ASPNETCont...ierarGrid.aspx


"mr killer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have an ASP.NET application simply displaying a DataGrid control on a
>form.
> Within some of the DataGrid cells I display multiple records within that
> cell based on an SQL query that loops through some table records.
> Unfortunately I can't format those records to be on there own separate
> line
> within the DataGrid cell, because the cell obviously just displays my
> results
> one after the other in the same cell. What I want to do is populate a
> separate DataTable, and store each record I grab in my query into its' own
> row within that DataTable. Then I want to display that DataTable within a
> specified DataGrid cell so the data will look stacked within the cell.
> This
> stems of the fact that HTML developers use tables for positioning data on
> a
> web-form, so I want to see if I can do the same thing within an ASP.NET
> DataGrid control. Is this possible? Thanks.
>
>


 
Reply With Quote
 
 
 
 
TenDot
Guest
Posts: n/a
 
      10-01-2004
Killer,

I'm not a great expert but one way to do this would be to pull 2 queries,
one for your parent table and one for your child table. Load them both into
the same dataset so you've got ds.Tables[0] and ds.Tables[1]. Then build a
relationship between the tables. When you put that into a grid you get a
list of parent records with a button that will show the child records.
Something like this:

DataSet dsDD = new DataSet( "CPRdd" );
string sqlCmd = "Select * from cprTables";
SqlDataAdapter da = new SqlDataAdapter( sqlCmd, this._cnxnCPRdd );
/// set up the tables in the DataSet
da.Fill( dsDD, "Tables" );
da.SelectCommand.CommandText = "Select * from cprFields order by FldName";
da.Fill( dsDD, "Fields" );
da.SelectCommand.CommandText = "Select * from TblComments order by
TblName";
da.Fill( dsDD, "TblCmts" );
da.SelectCommand.CommandText = "Select * from FldComments order by
FldName";
da.Fill( dsDD, "FldCmts" );

/// -----------------------------------------------------------
/// build the relations for each table:
/// -----------------------------------------------------------
/// Tables table to Fields
dsDD.Relations.Add( "TableFields",
dsDD.Tables["Tables"].Columns["Pk_table"],dsDD.Tables["Fields"].Columns["TblKey"]);
/// relate Comments to Tables
dsDD.Relations.Add( "TableComment",
dsDD.Tables["Tables"].Columns["TblName"],dsDD.Tables["TblCmts"].Columns["TblName"]);

I hope that helps.



"mr killer" wrote:

> I have an ASP.NET application simply displaying a DataGrid control on a form.
> Within some of the DataGrid cells I display multiple records within that
> cell based on an SQL query that loops through some table records.
> Unfortunately I can't format those records to be on there own separate line
> within the DataGrid cell, because the cell obviously just displays my results
> one after the other in the same cell. What I want to do is populate a
> separate DataTable, and store each record I grab in my query into its' own
> row within that DataTable. Then I want to display that DataTable within a
> specified DataGrid cell so the data will look stacked within the cell. This
> stems of the fact that HTML developers use tables for positioning data on a
> web-form, so I want to see if I can do the same thing within an ASP.NET
> DataGrid control. Is this possible? Thanks.
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sort a datatable and create a new datatable Fredrik Rodin ASP .Net 3 09-28-2007 07:28 AM
Displaying a DataTable within a DataGrid cell mr killer ASP .Net Web Controls 0 09-29-2004 01:23 PM
How do I have a table cell fetch another page to display within the cell? Phillip Roncoroni HTML 14 04-05-2004 05:58 PM
Casting DataTable to class inherit from DataTable =?Utf-8?B?Qmx1ZWZsb3dlcg==?= ASP .Net 0 04-02-2004 05:41 AM
Adding DataTable Rows To another DataTable J. Babe ASP .Net 1 08-15-2003 05:04 PM



Advertisments