473,396 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

datatable.newrow HOW THE HELL

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 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>8vQYdYVFmk25p40lYSNEKA==</Id>
Jul 21 '05 #1
1 2214

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

C#
DataRow dro = DataTableName.NewRow();
dro[0] = "whatever";
dro[1] = "you get the idea";
DataTableName.Rows.Add(dro);

VB.NET
Dim dro as DataRow = new DataRow
dro(0) = "whatever"
dro(1) = "you get the idea"
DataTableName.Rows.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*******@dotnet247.com> wrote in message
news:uz**************@tk2msftngp13.phx.gbl...
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 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>8vQYdYVFmk25p40lYSNEKA==</Id>

Jul 21 '05 #2

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

Similar topics

7
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...
1
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,...
1
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...
2
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...
2
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...
1
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...
1
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...
0
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: ...
3
by: Bimal Kothari | last post by:
private DataTable SortDataTable(DataTable GetDataTable, string sort) { DataTable _NewDataTable = GetDataTable.Clone(); int rowCount = GetDataTable.Rows.Count; DataRow foundRows =...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...
0
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,...

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.