473,772 Members | 2,244 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple grid/table display question.

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
5 3075
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.co m

"Will" <de*@rusmo.co m> wrote in message
news:je******** ************@gi ganews.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
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.Ad d(dr);

dr = myTable.NewRow( );
dr["ID"] = "13E";
dr["Name"] = "Dweezil";
dr["Address"] = "123 Main St";
myTable.Rows.Ad d(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
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.co m> wrote in message
news:je******** ************@gi ganews.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
thanks, Nicholas - you've been very helpful.
Nov 15 '05 #5
Perfect example - thanks for taking the time to include some source.

Will.
Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4880
by: Jordan O'Hare | last post by:
Hello Everyone, I am after some help with the following: I have a windows application that contains a list box and two data grids. All three controls are binded to a dataset that contains five tables, and three relations that I want to take advantage of. Everything works fine however I want to use the data grid table style editor to make it look more presentable. Currently I have successfully done this
4
2564
by: Carlos Lozano | last post by:
Hello Folks! I have a grid that populates from a table on SQL Server. All datetime with DBNull value show 1/1/1900 12:00AM ... Instead of just blank (""). I found a document with the following code, but didn't work. public void setGridColumnStyle() { DataGridColumnStyle newColStyle;
3
2219
by: pmud | last post by:
Hi, I have a web page (asp.net, code:c#). I havean html table with text boxes. Based on the user input , records are displayed in the data grid below it. Now the datagrid has a large no. of columns. & depending on what the user enters, the data grid can grow very large. So to avoid scrolling the whole page, I just want the data grid to be scrollable. For this I used the <div> tags around the data grid, <div...
10
1940
by: John Wilson | last post by:
My app produces some long datatables to display in a grid. So I put them in a div so users can scroll. But the grid headers scroll out of view. I would like to stop them doing this. Can I fix them in place at the top of the div? -- John Wilson
13
1860
by: Saber | last post by:
I did a lot of searches and read something about datagrids. But I couldn't find the answer of my simple question, how can I show only my desired columns of a table? for example I wrote this sql query: OleDbDataAdapter1.SelectCommand.CommandText = & _ "Select illNameE From tblIllness" OleDbDataAdapter1.Fill(DsIllness1) But in my datagrid, I get (null) for other ccolumns instead
1
1055
by: Jason | last post by:
Hello I've got a VB.net datagrid that I use to display some inforamtion from a Acess DB. In my datagrid I only display a few items of informatin, because there are just to many cells per tuple to realisticaly display on each line in the datagrid. My question... How do I allow it, so that if I were to doubleclick (or use the enter key) the data grid row another form is displays all the iformation that is in that particular row? ...
117
18575
by: phil-news-nospam | last post by:
Is there really any advantage to using DIV elements with float style properies, vs. the old method of TABLE and TR and TD? I'm finding that by using DIV, it still involves the same number of elements in the HTML to get everything just right. When you consider the class attribute on the DIV elements, there's not much size savings anymore for using DIV. There are other disadvantages to not using TABLE/TR/TD, such as the lack of ability...
0
2005
by: simon | last post by:
hello, relatively new to .net, i'm using vb.net and the 2.0 .net platform I'm trying to display a grid that has a text box on the left in one cell (with a hidden ID), which will be associated to multiple rows (events) on the right. each row on the right will also have a text box ------------------------------------------------------- event 1
6
7997
by: Romulo NF | last post by:
Greetings again to everyone, Im back to show this grid componenet i´ve developed. With this grid you can show the data like a normal table, remove the rows that you need, add rows, import data, call determined functions, and edit the data already present What will you need to use the grid? A table with standard markup and an ID to call the script that will turn the table into a grid Parameters: tabelaID => id of the table that will...
0
9620
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6715
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.