Hi All,
Not sure if parsing is the correct word but here is what I'm trying to
do:
I have a method that returns a dataset that uses a select statement
that comprises three union all'd select statements (i.e. "select
author from table1 union all select author from table 2...").
The end result is a small dataset with one column and four rows
including the column header (three rows of data). What I'm trying to
do is iterate through the column asiging each row (there's only one
field per row) to a three different text boxes. I've done this a
hundred times with one row and many columns using code similar to
this:
foreach (DataRow dr in dt.Rows)
{
txt1.Text = dr[0].ToString();
txt2.Text = dr[1].ToString();
txt3.Text = dr[2].ToString();
}
But can't figure out how to iterate vertically through a column using
a similar method. How do I di that?
Thanks for any help. 3 1478
What do you mean by iterating vertically through a column? Can you give an
example as to what you are trying to achive?
Adrian.
--
[Please mark my answer if it was helpful to you]
"Looch" wrote:
Hi All,
Not sure if parsing is the correct word but here is what I'm trying to
do:
I have a method that returns a dataset that uses a select statement
that comprises three union all'd select statements (i.e. "select
author from table1 union all select author from table 2...").
The end result is a small dataset with one column and four rows
including the column header (three rows of data). What I'm trying to
do is iterate through the column asiging each row (there's only one
field per row) to a three different text boxes. I've done this a
hundred times with one row and many columns using code similar to
this:
foreach (DataRow dr in dt.Rows)
{
txt1.Text = dr[0].ToString();
txt2.Text = dr[1].ToString();
txt3.Text = dr[2].ToString();
}
But can't figure out how to iterate vertically through a column using
a similar method. How do I di that?
Thanks for any help.
Adrian,
The dataset that I'm returning has only one column (col1) and four
rows(row1 - row4). I would like the data from col1,row1 in textbox1,
the data from col1,row2 in textbox2, data from col1,row3 in
textbox3...etc.
Thanks
On Aug 16, 7:01 am, Looch <lucianoj2...@y ahoo.comwrote:
Adrian,
The dataset that I'm returning has only one column (col1) and four
rows(row1 - row4). I would like the data from col1,row1 in textbox1,
the data from col1,row2 in textbox2, data from col1,row3 in
textbox3...etc.
Thanks
What I did was created an ArrayList and added all of my textboxes to
it. Then using a simple FOR loop, I iterated through the DataTable
placing the values into the textboxes:
ArrayList aList = new ArrayList();
aList.Add(textB ox1);
aList.Add(textB ox2);
aList.Add(textB ox3);
for (int i = 0; i < dt.Rows.Count-1; i++)
{
((TextBox)aList[i]).Text = ((DataRow)dt.Ro ws[i])[0].ToString();
}
A bit ugly and I know it can be cleaned up. I'm interested to know if
you come up with anything as well. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: J |
last post by:
Is there anyway to format a calculated datacolumn? I would like the
following column to display as money (formatted as $#,##0.00). Or how about
simply displaying the column formatted as a number with only 2 decimals
(#,##0.00)?
In the sample below, amount and taxrate are existing DataColumn's.
DataColumn colTax = new DataColumn();
colTax.DataType = System.Type.GetType("System.String");
colTax.ColumnName = "tax";...
|
by: Chris |
last post by:
I'm having trouble Serializing a System.Data.DataColumn
object. When I try to serialize it, I get the following:
System.NotSupportedException: Cannot serialize member
System.ComponentModel.MarshalByValueComponent.Site of
type System.ComponentModel.ISite because it is an
interface.
I tried a number of workarounds without sucess:
|
by: JC Voon |
last post by:
Hi:
How to reset the autoincrement value generated by DataTable ?
I've master and detail table, the detail table has a autoincrement
column, each time i add a new master record, i need to reset the
detail table autoincrement column to start from 1.
I set the dataColumn AutoIncrementSeed=0 and AutoIncrementStep=1 each
time i append a new master row, but it seem not work, it still remain
|
by: bordsby |
last post by:
Situation:
I am using an OleDbDataAdapter to fill a DataSet's DataTable with data
from an Access database. The DataSet's DataTable is bound to a
DataGrid. After the OleDbDataAdapter.Fill method is called, the
DataGrid displays the column headings as the column names output from
the Access SQL query. I would like to change some of the styles for
certain columns in the DataGrid, so I first need to set the
DataGridColumnStyle.MappingName...
|
by: mfunkmann |
last post by:
Hi,
I recently got an error and I don't know how to fix it:
Error 1 'System.Data.DataColumn' does not contain a definition for
'Windows' C:\c#\CsharpPRO\Form1.Designer.cs 304 77 CsharpPRO
I am note sure what to do because all propertiers work, except the
System.Data.DataColumn..
I didn't write any code by hand and used the visual studio to set the
properties..
| |
by: Matt F |
last post by:
I'm trying to do something that seems like it should be pretty simple, but
haven't found a solution. I am trying to add a datacolumn to a datatable
that adds or subtracts a number of days based on another datetime column in
the table. See sample below. How do I do this? Any help would be greatly
appreciated. Thanks
Private Sub CreateDataTable()
dt = New DataTable
|
by: SWIL |
last post by:
Hi,
I made my own datacolumn Class which inherits from Data.DataColumn. To this class I have added 2 properties.
To add datacolumn created through my new class I have to call..
DataSet.Table.Column.Add method
which is a part of datacolumncollection , where the defined data column type is Data.DataColumn and not my custom column.
Thus I have no method to access my datacolumn properties through dataset.
|
by: DaveP |
last post by:
im Trying to set a Datacolumn type for a new table
boolean is not working, What is the correct waty
//column.DataType = System.Type.GetType"System.Data.SqlTypes.SqlBoolean");
column.DataType = System.Type.GetType"System.Boolean"); //"System.Boolean");
tia
|
by: SMH |
last post by:
Hi All,
I am currently learning .Net 2, studying for 70-528. I've hit a bit of
a brick wall with DataColumn.Expression. As I understand it, this can
be used to (For example) concatenate two columns to make a derived
column.
When I run my code, I get this error:
------------
|
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...
|
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...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |