. Net 3.5 environment tree control for web form.
John. webcontrols. Tree for. Net 3.5 RTM (Please click to download)
:
This control inherits webcontrol's Treeview, which is just for our small-sized development at ordinary times (for unlimited trees, single table ID and PID). When the data volume exceeds 20 thousand, it will be compared.
HTML:
<Johncontrols: Treeview id = "treeview1" runat = "server" navigateurlformat = "page1.aspx? Id = {0}, page2.aspx? Xxx = {0} & amp; DSSS = {1}, page3.aspx "navigateurlkey =" ID, text "rootparentid =" 0 "> </johncontrols: Treeview>
Code:
String connstring = @ "Data Source =./sqlexpress; attachdbfilename = F:/johnv3.0/wwwroot/test/app_data/basesystem. MDF; Integrated Security = true; user instance = true ";
Dataset DS = John. commons. Utility. dbmssqlutility. executedataset (connstring, "select * From t_basemulticode ");
This. treeview1.datasource = Ds;
This. treeview1.databind ();
I have published John. commons. Utility. dbmssqlutility in the above code. You can find it.
The following attributes are important:
All key attributes are database Field Names, representing the values at each location. According to the requirements, some user-friendly changes have been made in navigateurl.
Because the navigateurl of each node may be the same or different. Therefore, the navigateurlformat attribute can be used to set the urlformat of each layer node as needed. The first layer represents the first layer, the last layer represents its location, and all subsequent layers.
The settings of the navigateurlformat attribute are as follows:
Settings of navigateurlkey:
The value of the ID field will be the same as the page1.aspx? Id = {0}, so it is easy to understand string. Format ("page1.aspx? Id = {0} ", value (" ID "))
The xxx = {0} of the second node is also combined with the ID field.
Since only one tag is set for the first layer, the text field is ignored by the first layer.
The value of the text field is combined into the DSS = {1} on the second layer. String. Format ("page2.aspx? Xxx = {0} & DSSS = {1} ", value (" ID ", value (text )))
In the above Code, there is actually no value at all, just to understand the working principle of the control.
The final result is the above. The address displayed in the status bar in the figure is the address of the first node.
Is the second layer address:
Layer 3 and later:
Http://www.cnblogs.com/Garnai/archive/2007/12/08/john-webcontrols-tree.html