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

Trying to extract Data from a DataTable

My DataTabel has the following columns: org_id, org_name, parent_id

DataTable dt = dsMyData.Tables["organization"];

This next statement should create a data view with filter that results in
one row

DataView dv = new DataView(dt,"parent_id
= -1","org_id",System.Data.DataViewRowState.CurrentRo ws);

I am trying to add the values from the org_id column to a TreeNode. Tag
field and the org_name column to the TreeNode.Text field. At least I think
that is what I want to do.

I want the org_name fields to be the visible part of the treeView and the
org_id fields to be the values that may be passed to other controls when a
node is selected.

My problem is that I can't figure out how to get at the values in DataTable
Columns.

Here is a sample I found regarding a DataRowView , but DataRowView is not a
member of the DataView...? I see other discussion that talk about an Item
member of a DataView, but my intellisense doesn't inidcate any such member
of a DataView.

The DataRowView sample seems in appropriate because I only have one row, or
at least should have.

[C#]
DataView catView = new DataView(catDS.Tables["Categories"]);

Console.WriteLine("Current Values:");

WriteView(catView);

Console.WriteLine("Original Values:");

catView.RowStateFilter = DataViewRowState.ModifiedOriginal;

WriteView(catView);

public static void WriteView(DataView myView)
{
foreach (DataRowView myDRV in myView)
{
for (int i = 0; i < myView.Table.Columns.Count; i++)
Console.Write(myDRV[i] + "\t");
Console.WriteLine();
}
}
TreeNode tn = new TreeNode();

What do I use to populate these fields?

tn.Text = dv.???

tn.tag = dv.???
Dec 1 '05 #1
0 1622

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

Similar topics

0
by: elcc1958 | last post by:
I need to support a VB6 application that will be receiving disconnected ADODB.Recordset from out DotNet solution. Our dotnet solution deals with System.Data.DataTable. I need to populate a...
2
by: scott | last post by:
Hi all First off, thank you for any one that can help. I have a problem trying to link a DataGrideTableStyle to a DataGrid. I have a dataset which reads from a file a xml schema and a xml...
0
by: Brian Hanson | last post by:
Hi, I have an unusual problem that just showed its ugly head at a pretty bad time. I have an asp.net (VB) app that takes data from an Excel sheet and puts it into SQL Server. I get the data...
1
by: Beginner | last post by:
hihi While I am developing ASP.NET using C# I want to import a excel file and make some modification and then generate a report however, I can't use SQL command as the excel file does not have...
6
by: Tejpal Garhwal | last post by:
I have datagrid filled with some data rows. At the run time i want know how many total rows are there in the data grid ? Any idea ? Any Suggestions ? Thanks in advance Tej
2
by: Mark | last post by:
Hello - From an Access VBA module, I'm trying to pass a Table to a VB.Net class. I'm getting the following error running the VBA: "Unable to cast object of type System._ComObject to type...
0
by: Henry | last post by:
I am trying to create a TreeView control that works with an ADO Dataset DataTable or the new BindingSource stuff in .NET 2.0 to build a Treeview that is populated. This is what I came up with...
7
by: JoeC | last post by:
I am trying to create a windows program that reads binary graphics as a resource. This has nothing to do with win32 but conversion of data with memcpy. graphic::graphic(UINT uiResID, HINSTANCE...
0
by: todubhai | last post by:
I am using the following code to extract the sheet names from excel: (See attached code) private String GetExcelSheetNames(string sConnectionString) { OleDbConnection objConn...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.