473,386 Members | 1,757 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,386 software developers and data experts.

Adding a blank row to a datatable

Roy
Hi all,
I do have a datatable that looks like:
id Number Description
1 1 Desc1
2 1 Desc2
3 2 Desc3
I need this datatable looks like (with 4 rows which the third one is blank):
id Number Description
1 1 Desc1
2 1 Desc2

3 2 Desc3
Any suggestions would be appreciated.
Roy

Nov 21 '05 #1
2 2435
Hi Roy,

Thats doesn;t really make sense. One of the primary tenants of a relational
databases is the the order of the rows is unimportant. Secondly why would
you want to store NOTHING?

If this is for some kind of output/report then you'd be better of telling
us what you're doing so we can advise with a another code based strategy.
If you want to stick with your blank row then you'll be relying on
inserting NULLs /and or white space. This will not be possible however if
your Id column is autonumbered/incrementing.

This will still not get you around any sorting however because this null
row will be placed at either the top or the bottom when sorted.

Richard

"Roy" <Ro*@discussions.microsoft.com> wrote in message
news:A3**********************************@microsof t.com...
Hi all,
I do have a datatable that looks like:
id Number Description
1 1 Desc1
2 1 Desc2
3 2 Desc3
I need this datatable looks like (with 4 rows which the third one is blank): id Number Description
1 1 Desc1
2 1 Desc2

3 2 Desc3
Any suggestions would be appreciated.
Roy

Nov 21 '05 #2
Roy
Hi Richard,
As you guessed this is for reporting purpose. I was not able to run a sql
statement that returns a datatable with the blank rows. The datatable has
already been sorted and I need to loop through the rows and check for the
Number column. If there is a change then I need to insert a blank row that
each column has a value of NULL. To do this I've created another datatable
and when I'm looping through the original datatable if there is not a change
in this column I insert the oringinal row into the new datatable otherwise I
insert a new record with null values. This is working, but it doesn't look
very impresive and I wonder if there is a better way to do this.
Thanks again
Roy

"Richard Myers" wrote:
Hi Roy,

Thats doesn;t really make sense. One of the primary tenants of a relational
databases is the the order of the rows is unimportant. Secondly why would
you want to store NOTHING?

If this is for some kind of output/report then you'd be better of telling
us what you're doing so we can advise with a another code based strategy.
If you want to stick with your blank row then you'll be relying on
inserting NULLs /and or white space. This will not be possible however if
your Id column is autonumbered/incrementing.

This will still not get you around any sorting however because this null
row will be placed at either the top or the bottom when sorted.

Richard

"Roy" <Ro*@discussions.microsoft.com> wrote in message
news:A3**********************************@microsof t.com...
Hi all,
I do have a datatable that looks like:
id Number Description
1 1 Desc1
2 1 Desc2
3 2 Desc3
I need this datatable looks like (with 4 rows which the third one is

blank):
id Number Description
1 1 Desc1
2 1 Desc2

3 2 Desc3
Any suggestions would be appreciated.
Roy


Nov 21 '05 #3

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

Similar topics

4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
6
by: Robert Schuldenfrei | last post by:
Dear NG, After being away from C# programming for a spell, I am trying my hand at what should be a simple task. I have been hitting my head against the wall this morning. I have a simple order...
2
by: Chris | last post by:
I was wondering if there was any way to add a blank list item control to the beginning of the System.Web.UI.WebControls.DropDownList's datasource after the control's datasource has been specified....
1
by: Andrew | last post by:
Hey all, I am very new to ASP.Net (and .Net in general), but that isn't stopping the boss from wanting to begin new projects in it. This latest project has me kinda stumped and after a couple...
2
by: Niels Jensen | last post by:
I have the following code in a Sub which is called by a do loop statement for each line starting with unit info in an e-mail based game that I play. I'm exctracting the keywords from the text and...
2
by: Sam | last post by:
hi, I have a combox in a datagrid linked to a dataset. I fill the dataset using my own customised class and it works fine. da.AddTable("select FieldTypeID, FieldType from FieldTypes",...
1
by: JohnR | last post by:
I'm using oledb to an Access datatable. I load the table into a dataset. I create databindings to link the fields on my form to the corresponding fields in the datatable. The tables...
9
by: Kay | last post by:
Hi all, Could you tell me the best way to add a blank item(as first item) in a data binded combo box? Because I think I didn't do it right and it generate an error if the second item(after the...
2
by: Flack | last post by:
Hey guys, I have a DataGrid and DataTable field in my class : private ImageDataGrid dataGrid1; //ImageDataGrid extends dataGrid and just overides OnMouseDown private DataTable dt = new...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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,...

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.