TreeNode.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803
  1. //
  2. // System.Web.UI.WebControls.TreeNode.cs
  3. //
  4. // Authors:
  5. // Lluis Sanchez Gual ([email protected])
  6. //
  7. // (C) 2004 Novell, Inc (http://www.novell.com)
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining
  10. // a copy of this software and associated documentation files (the
  11. // "Software"), to deal in the Software without restriction, including
  12. // without limitation the rights to use, copy, modify, merge, publish,
  13. // distribute, sublicense, and/or sell copies of the Software, and to
  14. // permit persons to whom the Software is furnished to do so, subject to
  15. // the following conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. //
  28. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  29. //
  30. #if NET_2_0
  31. using System;
  32. using System.Collections;
  33. using System.Text;
  34. using System.ComponentModel;
  35. using System.Web.UI;
  36. namespace System.Web.UI.WebControls
  37. {
  38. [ParseChildrenAttribute (true, "ChildNodes")]
  39. public class TreeNode: IStateManager, ICloneable
  40. {
  41. StateBag ViewState = new StateBag ();
  42. TreeNodeCollection nodes;
  43. bool marked;
  44. TreeView tree;
  45. TreeNode parent;
  46. int index;
  47. string path;
  48. int depth = -1;
  49. object dataItem;
  50. IHierarchyData hierarchyData;
  51. bool gotBinding;
  52. TreeNodeBinding binding;
  53. PropertyDescriptorCollection boundProperties;
  54. internal TreeNode (TreeView tree)
  55. {
  56. Tree = tree;
  57. }
  58. public TreeNode ()
  59. {
  60. }
  61. public TreeNode (string text)
  62. {
  63. Text = text;
  64. }
  65. public TreeNode (string text, string value)
  66. {
  67. Text = text;
  68. Value = value;
  69. }
  70. public TreeNode (string text, string value, string imageUrl)
  71. {
  72. Text = text;
  73. Value = value;
  74. ImageUrl = imageUrl;
  75. }
  76. public TreeNode (string text, string value, string imageUrl, string navigateUrl, string target)
  77. {
  78. Text = text;
  79. Value = value;
  80. ImageUrl = imageUrl;
  81. NavigateUrl = navigateUrl;
  82. Target = target;
  83. }
  84. [MonoTODO ("Not implemented")]
  85. protected TreeNode (TreeView owner, bool isRoot)
  86. {
  87. throw new NotImplementedException ();
  88. }
  89. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  90. [Browsable (false)]
  91. public int Depth {
  92. get {
  93. if (depth != -1) return depth;
  94. depth = 0;
  95. TreeNode nod = parent;
  96. while (nod != null) {
  97. depth++;
  98. nod = nod.parent;
  99. }
  100. return depth;
  101. }
  102. }
  103. void ResetPathData ()
  104. {
  105. path = null;
  106. depth = -1;
  107. gotBinding = false;
  108. if (nodes != null) {
  109. foreach (TreeNode node in nodes)
  110. node.ResetPathData ();
  111. }
  112. }
  113. internal TreeView Tree {
  114. get { return tree; }
  115. set {
  116. if (SelectedFlag) {
  117. if (value != null)
  118. value.SetSelectedNode (this, false);
  119. if (tree != null)
  120. tree.SetSelectedNode (null, false);
  121. }
  122. tree = value;
  123. if (nodes != null)
  124. nodes.SetTree (tree);
  125. ResetPathData ();
  126. if (PopulateOnDemand && !Populated && Expanded.HasValue && Expanded.Value)
  127. Populate ();
  128. }
  129. }
  130. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  131. [DefaultValue (false)]
  132. [Browsable (false)]
  133. public bool DataBound {
  134. get { return ViewState ["DataBound"] == null ? false : (bool) ViewState ["DataBound"]; }
  135. private set { ViewState ["DataBound"] = value; }
  136. }
  137. [DefaultValue (null)]
  138. [Browsable (false)]
  139. public object DataItem {
  140. get {
  141. return dataItem;
  142. }
  143. }
  144. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  145. [DefaultValue ("")]
  146. [Browsable (false)]
  147. public string DataPath {
  148. get { return ViewState ["DataPath"] == null ? String.Empty : (String) ViewState ["DataPath"]; }
  149. private set { ViewState ["DataPath"] = value; }
  150. }
  151. [DefaultValue (false)]
  152. public bool Checked {
  153. get {
  154. object o = ViewState ["Checked"];
  155. if (o != null) return (bool)o;
  156. return false;
  157. }
  158. set {
  159. ViewState ["Checked"] = value;
  160. if (tree != null)
  161. tree.NotifyCheckChanged (this);
  162. }
  163. }
  164. [DefaultValue (null)]
  165. [MergableProperty (false)]
  166. [Browsable (false)]
  167. [PersistenceMode (PersistenceMode.InnerDefaultProperty)]
  168. public TreeNodeCollection ChildNodes {
  169. get {
  170. if (nodes == null) {
  171. nodes = new TreeNodeCollection (this);
  172. if (IsTrackingViewState)
  173. ((IStateManager)nodes).TrackViewState();
  174. }
  175. return nodes;
  176. }
  177. }
  178. [DefaultValue (null)]
  179. public bool? Expanded {
  180. get {
  181. object o = ViewState ["Expanded"];
  182. return (bool?)o;
  183. }
  184. set {
  185. bool? current = (bool?) ViewState ["Expanded"];
  186. if (current == value)
  187. return;
  188. ViewState ["Expanded"] = value;
  189. if (tree != null)
  190. tree.NotifyExpandedChanged (this);
  191. if (PopulateOnDemand && !Populated && value.HasValue && value.Value)
  192. Populate ();
  193. }
  194. }
  195. [Localizable (true)]
  196. [DefaultValue ("")]
  197. public string ImageToolTip {
  198. get {
  199. object o = ViewState ["ImageToolTip"];
  200. if (o != null) return (string)o;
  201. return "";
  202. }
  203. set {
  204. ViewState ["ImageToolTip"] = value;
  205. }
  206. }
  207. [DefaultValue ("")]
  208. [UrlProperty]
  209. [Editor ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
  210. public string ImageUrl {
  211. get {
  212. object o = ViewState ["ImageUrl"];
  213. if (o != null) return (string)o;
  214. return "";
  215. }
  216. set {
  217. ViewState ["ImageUrl"] = value;
  218. }
  219. }
  220. [DefaultValue ("")]
  221. [UrlProperty]
  222. [Editor ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
  223. public string NavigateUrl {
  224. get {
  225. object o = ViewState ["NavigateUrl"];
  226. if (o != null) return (string)o;
  227. return "";
  228. }
  229. set {
  230. ViewState ["NavigateUrl"] = value;
  231. }
  232. }
  233. [DefaultValue (false)]
  234. public bool PopulateOnDemand {
  235. get {
  236. object o = ViewState ["PopulateOnDemand"];
  237. if (o != null) return (bool)o;
  238. return false;
  239. }
  240. set {
  241. ViewState ["PopulateOnDemand"] = value;
  242. }
  243. }
  244. [DefaultValue (TreeNodeSelectAction.Select)]
  245. public TreeNodeSelectAction SelectAction {
  246. get {
  247. object o = ViewState ["SelectAction"];
  248. if (o != null) return (TreeNodeSelectAction)o;
  249. return TreeNodeSelectAction.Select;
  250. }
  251. set {
  252. ViewState ["SelectAction"] = value;
  253. }
  254. }
  255. [DefaultValue (null)]
  256. public bool? ShowCheckBox {
  257. get {
  258. object o = ViewState ["ShowCheckBox"];
  259. return (bool?)o;
  260. }
  261. set {
  262. ViewState ["ShowCheckBox"] = value;
  263. }
  264. }
  265. internal bool ShowCheckBoxInternal {
  266. get {
  267. if (ShowCheckBox.HasValue)
  268. return ShowCheckBox.Value;
  269. else
  270. return (Tree.ShowCheckBoxes == TreeNodeTypes.All) ||
  271. ((Tree.ShowCheckBoxes & TreeNodeTypes.Leaf) > 0 && IsLeafNode) ||
  272. ((Tree.ShowCheckBoxes & TreeNodeTypes.Parent) > 0 && IsParentNode && Parent != null) ||
  273. ((Tree.ShowCheckBoxes & TreeNodeTypes.Root) > 0 && Parent == null && ChildNodes.Count > 0);
  274. }
  275. }
  276. [DefaultValue ("")]
  277. public string Target {
  278. get {
  279. object o = ViewState ["Target"];
  280. if(o != null) return (string)o;
  281. return "";
  282. }
  283. set {
  284. ViewState ["Target"] = value;
  285. }
  286. }
  287. [Localizable (true)]
  288. [DefaultValue ("")]
  289. [WebSysDescription ("The display text of the tree node.")]
  290. public string Text {
  291. get {
  292. object o = ViewState ["Text"];
  293. if (o == null)
  294. o = ViewState ["Value"];
  295. if (o != null) return (string)o;
  296. return String.Empty;
  297. }
  298. set {
  299. ViewState ["Text"] = value;
  300. }
  301. }
  302. [Localizable (true)]
  303. [DefaultValue ("")]
  304. public string ToolTip {
  305. get {
  306. object o = ViewState ["ToolTip"];
  307. if(o != null) return (string)o;
  308. return "";
  309. }
  310. set {
  311. ViewState ["ToolTip"] = value;
  312. }
  313. }
  314. [Localizable (true)]
  315. [DefaultValue ("")]
  316. public string Value {
  317. get {
  318. object o = ViewState ["Value"];
  319. if (o == null)
  320. o = ViewState ["Text"];
  321. if(o != null) return (string)o;
  322. return String.Empty;
  323. }
  324. set {
  325. ViewState ["Value"] = value;
  326. }
  327. }
  328. [DefaultValue (false)]
  329. public bool Selected {
  330. get {
  331. return SelectedFlag;
  332. }
  333. set {
  334. SelectedFlag = value;
  335. if (tree != null) {
  336. if (!value && tree.SelectedNode == this)
  337. tree.SetSelectedNode (null, false);
  338. else if (value)
  339. tree.SetSelectedNode (this, false);
  340. }
  341. }
  342. }
  343. internal virtual bool SelectedFlag {
  344. get {
  345. object o = ViewState ["Selected"];
  346. if(o != null) return (bool)o;
  347. return false;
  348. }
  349. set {
  350. ViewState ["Selected"] = value;
  351. }
  352. }
  353. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  354. [Browsable (false)]
  355. public TreeNode Parent {
  356. get { return parent; }
  357. }
  358. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  359. [Browsable (false)]
  360. public string ValuePath {
  361. get {
  362. if (tree == null) return Value;
  363. StringBuilder sb = new StringBuilder (Value);
  364. TreeNode node = parent;
  365. while (node != null) {
  366. sb.Insert (0, tree.PathSeparator);
  367. sb.Insert (0, node.Value);
  368. node = node.Parent;
  369. }
  370. return sb.ToString ();
  371. }
  372. }
  373. internal int Index {
  374. get { return index; }
  375. set { index = value; ResetPathData (); }
  376. }
  377. internal void SetParent (TreeNode node) {
  378. parent = node;
  379. ResetPathData ();
  380. }
  381. internal string Path {
  382. get {
  383. if (path != null) return path;
  384. StringBuilder sb = new StringBuilder (index.ToString());
  385. TreeNode node = parent;
  386. while (node != null) {
  387. sb.Insert (0, '_');
  388. sb.Insert (0, node.Index.ToString ());
  389. node = node.Parent;
  390. }
  391. path = sb.ToString ();
  392. return path;
  393. }
  394. }
  395. internal bool Populated {
  396. get {
  397. object o = ViewState ["Populated"];
  398. if (o != null) return (bool) o;
  399. return false;
  400. }
  401. set {
  402. ViewState ["Populated"] = value;
  403. }
  404. }
  405. internal bool HasChildData {
  406. get { return nodes != null; }
  407. }
  408. internal void Populate ()
  409. {
  410. if (tree == null)
  411. return;
  412. Populated = true;
  413. tree.NotifyPopulateRequired (this);
  414. }
  415. public void Collapse ()
  416. {
  417. Expanded = false;
  418. }
  419. public void CollapseAll ()
  420. {
  421. SetExpandedRec (false, -1);
  422. }
  423. public void Expand ()
  424. {
  425. Expanded = true;
  426. }
  427. internal void Expand (int depth)
  428. {
  429. SetExpandedRec (true, depth);
  430. }
  431. public void ExpandAll ()
  432. {
  433. SetExpandedRec (true, -1);
  434. }
  435. void SetExpandedRec (bool expanded, int depth)
  436. {
  437. Expanded = expanded;
  438. if (depth == 0) return;
  439. foreach (TreeNode nod in ChildNodes)
  440. nod.SetExpandedRec (expanded, depth - 1);
  441. }
  442. public void Select ()
  443. {
  444. Selected = true;
  445. }
  446. public void ToggleExpandState ()
  447. {
  448. #if TARGET_JVM //No support for Nullable<bool>.GetValueOrDefault() yet
  449. bool? value = Expanded;
  450. Expanded = value.HasValue ? !value.Value : true;
  451. #else
  452. Expanded = !Expanded.GetValueOrDefault(false);
  453. #endif
  454. }
  455. void IStateManager.LoadViewState (object savedState)
  456. {
  457. LoadViewState (savedState);
  458. }
  459. protected virtual void LoadViewState (object savedState)
  460. {
  461. if (savedState == null)
  462. return;
  463. object[] states = (object[]) savedState;
  464. ViewState.LoadViewState (states [0]);
  465. if (tree != null && SelectedFlag)
  466. tree.SetSelectedNode (this, true);
  467. if (!PopulateOnDemand || Populated)
  468. ((IStateManager)ChildNodes).LoadViewState (states [1]);
  469. }
  470. object IStateManager.SaveViewState ()
  471. {
  472. return SaveViewState ();
  473. }
  474. protected virtual object SaveViewState ()
  475. {
  476. object[] states = new object[2];
  477. states[0] = ViewState.SaveViewState();
  478. states[1] = (nodes == null ? null : ((IStateManager)nodes).SaveViewState());
  479. for (int i = 0; i < states.Length; i++) {
  480. if (states [i] != null)
  481. return states;
  482. }
  483. return null;
  484. }
  485. void IStateManager.TrackViewState ()
  486. {
  487. TrackViewState ();
  488. }
  489. protected void TrackViewState ()
  490. {
  491. if (marked) return;
  492. marked = true;
  493. ViewState.TrackViewState();
  494. if (nodes != null)
  495. ((IStateManager)nodes).TrackViewState ();
  496. }
  497. bool IStateManager.IsTrackingViewState {
  498. get { return IsTrackingViewState; }
  499. }
  500. protected bool IsTrackingViewState
  501. {
  502. get { return marked; }
  503. }
  504. internal void SetDirty ()
  505. {
  506. ViewState.SetDirty (true);
  507. if (nodes != null)
  508. nodes.SetDirty ();
  509. }
  510. public virtual object Clone ()
  511. {
  512. TreeNode nod = tree != null ? tree.CreateNode () : new TreeNode ();
  513. foreach (DictionaryEntry e in ViewState)
  514. nod.ViewState [(string)e.Key] = ((StateItem)e.Value).Value;
  515. foreach (TreeNode c in ChildNodes)
  516. nod.ChildNodes.Add ((TreeNode)c.Clone ());
  517. return nod;
  518. }
  519. object ICloneable.Clone () {
  520. return Clone ();
  521. }
  522. internal void Bind (IHierarchyData hierarchyData)
  523. {
  524. this.hierarchyData = hierarchyData;
  525. DataBound = true;
  526. DataPath = hierarchyData.Path;
  527. dataItem = hierarchyData.Item;
  528. TreeNodeBinding bin = GetBinding ();
  529. if (bin != null) {
  530. // Bind ImageToolTip property
  531. if (bin.ImageToolTipField.Length > 0) {
  532. ImageToolTip = Convert.ToString (GetBoundPropertyValue (bin.ImageToolTipField));
  533. if (ImageToolTip.Length == 0)
  534. ImageToolTip = bin.ImageToolTip;
  535. }
  536. else if (bin.ImageToolTip.Length > 0)
  537. ImageToolTip = bin.ImageToolTip;
  538. // Bind ImageUrl property
  539. if (bin.ImageUrlField.Length > 0) {
  540. ImageUrl = Convert.ToString (GetBoundPropertyValue (bin.ImageUrlField));
  541. if (ImageUrl.Length == 0)
  542. ImageUrl = bin.ImageUrl;
  543. }
  544. else if (bin.ImageUrl.Length > 0)
  545. ImageUrl = bin.ImageUrl;
  546. // Bind NavigateUrl property
  547. if (bin.NavigateUrlField.Length > 0) {
  548. NavigateUrl = Convert.ToString (GetBoundPropertyValue (bin.NavigateUrlField));
  549. if (NavigateUrl.Length == 0)
  550. NavigateUrl = bin.NavigateUrl;
  551. }
  552. else if (bin.NavigateUrl.Length > 0)
  553. NavigateUrl = bin.NavigateUrl;
  554. // Bind PopulateOnDemand property
  555. if (bin.HasPropertyValue ("PopulateOnDemand"))
  556. PopulateOnDemand = bin.PopulateOnDemand;
  557. // Bind SelectAction property
  558. if (bin.HasPropertyValue ("SelectAction"))
  559. SelectAction = bin.SelectAction;
  560. // Bind ShowCheckBox property
  561. if (bin.HasPropertyValue ("ShowCheckBox"))
  562. ShowCheckBox = bin.ShowCheckBox;
  563. // Bind Target property
  564. if (bin.TargetField.Length > 0) {
  565. Target = Convert.ToString (GetBoundPropertyValue (bin.TargetField));
  566. if (Target.Length == 0)
  567. Target = bin.Target;
  568. }
  569. else if (bin.Target.Length > 0)
  570. Target = bin.Target;
  571. // Bind Text property
  572. string text = null;
  573. if (bin.TextField.Length > 0) {
  574. text = Convert.ToString (GetBoundPropertyValue (bin.TextField));
  575. if (bin.FormatString.Length > 0)
  576. text = string.Format (bin.FormatString, text);
  577. }
  578. if (String.IsNullOrEmpty (text)) {
  579. if (bin.Text.Length > 0)
  580. text = bin.Text;
  581. else if (bin.Value.Length > 0)
  582. text = bin.Value;
  583. }
  584. if (!String.IsNullOrEmpty (text))
  585. Text = text;
  586. // Bind ToolTip property
  587. if (bin.ToolTipField.Length > 0) {
  588. ToolTip = Convert.ToString (GetBoundPropertyValue (bin.ToolTipField));
  589. if (ToolTip.Length == 0)
  590. ToolTip = bin.ToolTip;
  591. }
  592. else if (bin.ToolTip.Length > 0)
  593. ToolTip = bin.ToolTip;
  594. // Bind Value property
  595. string value = null;
  596. if (bin.ValueField.Length > 0) {
  597. value = Convert.ToString (GetBoundPropertyValue (bin.ValueField));
  598. }
  599. if (String.IsNullOrEmpty (value)) {
  600. if (bin.Value.Length > 0)
  601. value = bin.Value;
  602. else if (bin.Text.Length > 0)
  603. value = bin.Text;
  604. }
  605. if (!String.IsNullOrEmpty (value))
  606. Value = value;
  607. }
  608. else {
  609. Text = Value = GetDefaultBoundText ();
  610. }
  611. INavigateUIData navigateUIData = hierarchyData as INavigateUIData;
  612. if (navigateUIData != null) {
  613. SelectAction = TreeNodeSelectAction.None;
  614. Text = navigateUIData.ToString ();
  615. NavigateUrl = navigateUIData.NavigateUrl;
  616. ToolTip = navigateUIData.Description;
  617. }
  618. }
  619. internal void SetDataItem (object item)
  620. {
  621. dataItem = item;
  622. }
  623. internal void SetDataPath (string path)
  624. {
  625. DataPath = path;
  626. }
  627. internal void SetDataBound (bool bound)
  628. {
  629. DataBound = bound;
  630. }
  631. string GetDefaultBoundText ()
  632. {
  633. if (hierarchyData != null) return hierarchyData.ToString ();
  634. else if (dataItem != null) return dataItem.ToString ();
  635. else return string.Empty;
  636. }
  637. string GetDataItemType ()
  638. {
  639. if (hierarchyData != null) return hierarchyData.Type;
  640. else if (dataItem != null) return dataItem.GetType().ToString ();
  641. else return string.Empty;
  642. }
  643. internal bool IsParentNode {
  644. get { return ChildNodes.Count > 0 || (PopulateOnDemand && !Populated); }
  645. }
  646. internal bool IsLeafNode {
  647. get { return !IsParentNode; }
  648. }
  649. internal bool IsRootNode {
  650. get { return Depth == 0; }
  651. }
  652. TreeNodeBinding GetBinding ()
  653. {
  654. if (tree == null) return null;
  655. if (gotBinding) return binding;
  656. binding = tree.FindBindingForNode (GetDataItemType (), Depth);
  657. gotBinding = true;
  658. return binding;
  659. }
  660. object GetBoundPropertyValue (string name)
  661. {
  662. if (boundProperties == null) {
  663. if (hierarchyData != null)
  664. boundProperties = TypeDescriptor.GetProperties (hierarchyData);
  665. else
  666. boundProperties = TypeDescriptor.GetProperties (dataItem);
  667. }
  668. PropertyDescriptor prop = boundProperties.Find (name, true);
  669. if (prop == null)
  670. throw new InvalidOperationException ("Property '" + name + "' not found in data bound item");
  671. if (hierarchyData != null)
  672. return prop.GetValue (hierarchyData);
  673. else
  674. return prop.GetValue (dataItem);
  675. }
  676. internal void BeginRenderText (HtmlTextWriter writer)
  677. {
  678. RenderPreText (writer);
  679. }
  680. internal void EndRenderText (HtmlTextWriter writer)
  681. {
  682. RenderPostText (writer);
  683. }
  684. protected virtual void RenderPreText (HtmlTextWriter writer)
  685. {
  686. }
  687. protected virtual void RenderPostText (HtmlTextWriter writer)
  688. {
  689. }
  690. }
  691. }
  692. #endif