Examples of Winform and database association operations (C #)

zhaozj2021-02-16  158

Winform underground and database associations are very common, the following code is used in the project, split from a table:

DataView DVTree;

Private Void InittreebyDataSet (TreenodeCollection NDS, String ParentID, DataSet DS)

{

Dvtree = new dataview ();

Treenode TempNode;

DVTree.table = ds.tables [0];

/ / Judgment whether the ParentServiceTypeID is NULL and generates different filtration conditions

IF (ParentID == "Isnull (ParentServiceTypeId, 'Null Column') = 'Null Column'")

{

Dvtree.rowfilter = ParentID;

}

Else

{

Dvtree.rowfilter = "ParentServiceTypeID = '" ParentID "'"

}

Foreach (DataRowView Drvtree In DVTree)

{

TempNode = New Treenode ();

TempNode.Text = drvtree ["name"]. TOSTRING ();

TempNode.tag = drvtree ["pkfieldvalue"]. TOSTRING ();

nds.add (tempnode);

// Recursive call

INITTREEBYDATASET (TempNode.Nodes, TempNode.tag.toT7tring (), DS);

}

}

Two related links:

"Application of tree structure in development",

Select the tree node and display it details

转载请注明原文地址:https://www.9cbs.com/read-7815.html

New Post(0)