473,806 Members | 2,967 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

datatable.newro w HOW THE HELL

could somebody please explain to me how the datatable.newro w method works, i've been trying to figure it out for weeks. I need to emulate it myself.

I can bind my datagrid to a collection of objects with no problem. But that leaves me with a fixed number of properties per object and therefore a fixed number of columns in my datagrid.

I wanted to do something similar to the datatable, where you add columns then have a method that generates a row object based on the column schema.

The reason i want to do this is to be able to hold objects in the table rather than scalar value as the datatable does.

Thanks in advance - i'm getting to the stage of dispear
--------------------------------
From: Al Bastido

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>8vQYdYVFmk2 5p40lYSNEKA==</Id>
Jul 21 '05 #1
1 2247

It'd help if you posted what you were currently doing, but this is
essentially the snytax:

C#
DataRow dro = DataTableName.N ewRow();
dro[0] = "whatever";
dro[1] = "you get the idea";
DataTableName.R ows.Add(dro);

VB.NET
Dim dro as DataRow = new DataRow
dro(0) = "whatever"
dro(1) = "you get the idea"
DataTableName.R ows.Add(dro)
--

With that said, I'm not sure how it relates to your problem. If you bind to
a datatable or a collection, you can add new values to it. If you
implemented a strongly typed collection then it would be quite easy, just
define a new instance of the object. As far as the columns go, I don't see
how it's any different other than not being as clean as a datatable. In
most instances, you can model quite a few things using a datatable directly.
If you look at what most ORM tools like Deklarit and LLBLGen do, the
effectively make the bridge between your object(s) and the dataTables(s),
which you can certainly do on your own although using one of those two tools
makes it a dream. You can get a good idea of how a datatable is implemented
by looking at its structure in the documentation. I may have misunderstood
your question though and If I did, please let me konw and I'll see what I
can do.

Cheers,

Bill

P.S. Be Kind and don't multipost ;-)

--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
"Al Bastido via .NET 247" <an*******@dotn et247.com> wrote in message
news:uz******** ******@tk2msftn gp13.phx.gbl...
could somebody please explain to me how the datatable.newro w method works, i've been trying to figure it out for weeks. I need to emulate it myself.
I can bind my datagrid to a collection of objects with no problem. But that leaves me with a fixed number of properties per object and therefore a
fixed number of columns in my datagrid.
I wanted to do something similar to the datatable, where you add columns then have a method that generates a row object based on the column schema.
The reason i want to do this is to be able to hold objects in the table rather than scalar value as the datatable does.
Thanks in advance - i'm getting to the stage of dispear
--------------------------------
From: Al Bastido

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>8vQYdYVFmk2 5p40lYSNEKA==</Id>

Jul 21 '05 #2

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

Similar topics

7
3402
by: Jason Callas | last post by:
I have a process that manages a list of trades. Each trade is a separate row in the table. I blast the process with 10,000 new trades in order to stress test it and end up with the below listed exception when I call the NewRow method. The number of times it happens is NOT consistent (sometimes a few times out of 10,000 and sometimes 1000+ times). The app is written in VB and I am using SyncLock everywhere the table is accessed but I am sure it...
1
2582
by: Tomas R | last post by:
I have a datagrid with a dataview(created from a DataTable) bind to it. It displayes coordinates and I have a toolbarbutton that will create a set of new coordinates just like the existing ones, accept that the x-values is mirrored. It's also possible to remove these coordinates, by a method that removes any row with negative x-values. This usually works fine a few times, mirroring and then removing. But then suddenly the NewRow statement...
1
2974
by: Mike | last post by:
I have an ASP.NET/VB app that updates values in a DataTable over the course of about 3 different pages. On the way out of the first of these pages, I explicitly build the DataTable from values in a DataGrid, and set the PrimaryKey of the DataTable to be the first cell in the grid (which is a UserID value). I then store the DataTable in a session object, from which it is retrieved for subsequent pages. All this seems to be working fine. ...
2
2124
by: ven | last post by:
Hello i have a dynamic datatable in my page. I wanna to write data to textboxes and after click on button "ADD data" i want to refresh datagrid on page... Here is my code : ' Insert page code here ' Dim wykszt as System.Data.DataTable Dim zatru as System.Data.DataTable Dim row as system.Data.DataRow
2
1780
by: DraguVaso | last post by:
Hi, I need a FAST way to put the content of a file in a datatable (one record for each line in the file). I have a routine for it, but it takes me too much time (2-5 seconds for each file) to put the lines in the datatable and do some actions. Does anybody knows a faster method? The fact is: I actually only need the lines starting with "0*" and "1*".
1
296
by: Al Bastido via .NET 247 | last post by:
could somebody please explain to me how the datatable.newrow method works, i've been trying to figure it out for weeks. I need to emulate it myself. I can bind my datagrid to a collection of objects with no problem. But that leaves me with a fixed number of properties per object and therefore a fixed number of columns in my datagrid. I wanted to do something similar to the datatable, where you add columns then have a method that generates...
1
5742
by: Maxwell2006 | last post by:
Hi, I am working with strongly typed datatables. What is the most efficient way to build a new DataTAble based on the result of DataTable.Select? At this point I use a foreach loop to do the work manually. I am looking for an automated way. Thank you, Max
0
1774
by: Maart_newbie | last post by:
Hi all, I've got a question about returning the value of a pk-column to a DataTable after inserting a row (via a data-adapter) using MySql5. Here is the SQL and code concerned: //=================================================================== // The table
3
5010
by: Bimal Kothari | last post by:
private DataTable SortDataTable(DataTable GetDataTable, string sort) { DataTable _NewDataTable = GetDataTable.Clone(); int rowCount = GetDataTable.Rows.Count; DataRow foundRows = GetDataTable.Select(null, sort); // Sort with Column name for (int i = 0; i < rowCount; i++) { object arr = new object;
0
9719
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
10620
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
10372
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,...
0
10110
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9187
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7650
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
5546
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...
2
3851
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.