By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,602 Members | 1,072 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,602 IT Pros & Developers. It's quick & easy.

Simple grid/table display question.

P: n/a
I've got a simple form that collects data from a user and I want to display
that data in a sortable grid or table. The nature of this data is rather
temporary, so there's no need to persist it to a database. Searching through
the Framework documentation, everything I've seen reggarding a grids and
tables seems to require a connection to a database. My guess is I'm just
missing something. What classes can I use to display sortable data in a grid
or table that don't require a DB connection?

Thanks in advance,
Will.
Nov 15 '05 #1
Share this Question
Share on Google+
5 Replies

P: n/a
Will,

The DataGrid can connect to anything that implements IList. Each row
will be whatever is served up by the IList interface. The grid uses
reflection to get the columns. However, if the type implements ITypedList
(like the DataView does), then it will query the members of that interface
to get the columns.

Also, the DataSet class (and DataTable, etc, etc classes) are not
connected to a database. You can create them and populate them as you wish,
without a database connection, and then pass this to the grid for binding.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Will" <de*@rusmo.com> wrote in message
news:je********************@giganews.com...
I've got a simple form that collects data from a user and I want to display that data in a sortable grid or table. The nature of this data is rather
temporary, so there's no need to persist it to a database. Searching through the Framework documentation, everything I've seen reggarding a grids and
tables seems to require a connection to a database. My guess is I'm just
missing something. What classes can I use to display sortable data in a grid or table that don't require a DB connection?

Thanks in advance,
Will.

Nov 15 '05 #2

P: n/a
You can create a DataTable to use as the data source for
your grid. Filling that table from a db is one option,
but it is not required.

using System.Data;

DataTable myTable = new DataTable("Info");
myTable.Columns.Add("ID");
myTable.Columns.Add("Name");
myTable.Columns.Add("Address");

DataRow dr = myTable.NewRow();
dr["ID"] = "4A";
dr["Name"] = "Johnny Frank";
dr["Address"] = "456 Second St";
myTable.Rows.Add(dr);

dr = myTable.NewRow();
dr["ID"] = "13E";
dr["Name"] = "Dweezil";
dr["Address"] = "123 Main St";
myTable.Rows.Add(dr);

this.dataGrid1.DataSource = myTable;

Charlie
-----Original Message-----
I've got a simple form that collects data from a user and I want to displaythat data in a sortable grid or table. The nature of this data is rathertemporary, so there's no need to persist it to a database. Searching throughthe Framework documentation, everything I've seen reggarding a grids andtables seems to require a connection to a database. My guess is I'm justmissing something. What classes can I use to display sortable data in a gridor table that don't require a DB connection?

Thanks in advance,
Will.
.

Nov 15 '05 #3

P: n/a
Will,
I personaly prefer to keep things inside a Dataset. I provides alot of
functionality for knowing which rows of data have been modified, deleted and
so forth. You can easily create one and fill a DataTable inside it with
DataRows as the user enters data. From this table, you can create a
DataView which can sort and filter rows for you. You can then bind the
DataView to your Datagrid.

hope this helps

Marco

"Will" <de*@rusmo.com> wrote in message
news:je********************@giganews.com...
I've got a simple form that collects data from a user and I want to display that data in a sortable grid or table. The nature of this data is rather
temporary, so there's no need to persist it to a database. Searching through the Framework documentation, everything I've seen reggarding a grids and
tables seems to require a connection to a database. My guess is I'm just
missing something. What classes can I use to display sortable data in a grid or table that don't require a DB connection?

Thanks in advance,
Will.

Nov 15 '05 #4

P: n/a
thanks, Nicholas - you've been very helpful.
Nov 15 '05 #5

P: n/a
Perfect example - thanks for taking the time to include some source.

Will.
Nov 15 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.