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.???