TreeNode.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799
  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. }
  109. internal TreeView Tree {
  110. get { return tree; }
  111. set {
  112. if (SelectedFlag) {
  113. if (value != null)
  114. value.SetSelectedNode (this, false);
  115. if (tree != null)
  116. tree.SetSelectedNode (null, false);
  117. }
  118. tree = value;
  119. if (nodes != null)
  120. nodes.SetTree (tree);
  121. ResetPathData ();
  122. if (PopulateOnDemand && !Populated && Expanded.HasValue && Expanded.Value)
  123. Populate ();
  124. }
  125. }
  126. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  127. [DefaultValue (false)]
  128. [Browsable (false)]
  129. public bool DataBound {
  130. get { return ViewState ["DataBound"] == null ? false : (bool) ViewState ["DataBound"]; }
  131. private set { ViewState ["DataBound"] = value; }
  132. }
  133. [DefaultValue (null)]
  134. [Browsable (false)]
  135. public object DataItem {
  136. get {
  137. return dataItem;
  138. }
  139. }
  140. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  141. [DefaultValue ("")]
  142. [Browsable (false)]
  143. public string DataPath {
  144. get { return ViewState ["DataPath"] == null ? String.Empty : (String) ViewState ["DataPath"]; }
  145. private set { ViewState ["DataPath"] = value; }
  146. }
  147. [DefaultValue (false)]
  148. public bool Checked {
  149. get {
  150. object o = ViewState ["Checked"];
  151. if (o != null) return (bool)o;
  152. return false;
  153. }
  154. set {
  155. ViewState ["Checked"] = value;
  156. if (tree != null)
  157. tree.NotifyCheckChanged (this);
  158. }
  159. }
  160. [DefaultValue (null)]
  161. [MergableProperty (false)]
  162. [Browsable (false)]
  163. [PersistenceMode (PersistenceMode.InnerDefaultProperty)]
  164. public TreeNodeCollection ChildNodes {
  165. get {
  166. if (nodes == null) {
  167. nodes = new TreeNodeCollection (this);
  168. if (IsTrackingViewState)
  169. ((IStateManager)nodes).TrackViewState();
  170. }
  171. return nodes;
  172. }
  173. }
  174. [DefaultValue (null)]
  175. public bool? Expanded {
  176. get {
  177. object o = ViewState ["Expanded"];
  178. return (bool?)o;
  179. }
  180. set {
  181. bool? current = (bool?) ViewState ["Expanded"];
  182. if (current == value)
  183. return;
  184. ViewState ["Expanded"] = value;
  185. if (tree != null)
  186. tree.NotifyExpandedChanged (this);
  187. if (PopulateOnDemand && !Populated && value.HasValue && value.Value)
  188. Populate ();
  189. }
  190. }
  191. [Localizable (true)]
  192. [DefaultValue ("")]
  193. public string ImageToolTip {
  194. get {
  195. object o = ViewState ["ImageToolTip"];
  196. if (o != null) return (string)o;
  197. return "";
  198. }
  199. set {
  200. ViewState ["ImageToolTip"] = value;
  201. }
  202. }
  203. [DefaultValue ("")]
  204. [UrlProperty]
  205. [Editor ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
  206. public string ImageUrl {
  207. get {
  208. object o = ViewState ["ImageUrl"];
  209. if (o != null) return (string)o;
  210. return "";
  211. }
  212. set {
  213. ViewState ["ImageUrl"] = value;
  214. }
  215. }
  216. [DefaultValue ("")]
  217. [UrlProperty]
  218. [Editor ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
  219. public string NavigateUrl {
  220. get {
  221. object o = ViewState ["NavigateUrl"];
  222. if (o != null) return (string)o;
  223. return "";
  224. }
  225. set {
  226. ViewState ["NavigateUrl"] = value;
  227. }
  228. }
  229. [DefaultValue (false)]
  230. public bool PopulateOnDemand {
  231. get {
  232. object o = ViewState ["PopulateOnDemand"];
  233. if (o != null) return (bool)o;
  234. return false;
  235. }
  236. set {
  237. ViewState ["PopulateOnDemand"] = value;
  238. }
  239. }
  240. [DefaultValue (TreeNodeSelectAction.Select)]
  241. public TreeNodeSelectAction SelectAction {
  242. get {
  243. object o = ViewState ["SelectAction"];
  244. if (o != null) return (TreeNodeSelectAction)o;
  245. return TreeNodeSelectAction.Select;
  246. }
  247. set {
  248. ViewState ["SelectAction"] = value;
  249. }
  250. }
  251. [DefaultValue (null)]
  252. public bool? ShowCheckBox {
  253. get {
  254. object o = ViewState ["ShowCheckBox"];
  255. return (bool?)o;
  256. }
  257. set {
  258. ViewState ["ShowCheckBox"] = value;
  259. }
  260. }
  261. internal bool ShowCheckBoxInternal {
  262. get {
  263. if (ShowCheckBox.HasValue)
  264. return ShowCheckBox.Value;
  265. else
  266. return (Tree.ShowCheckBoxes == TreeNodeTypes.All) ||
  267. ((Tree.ShowCheckBoxes & TreeNodeTypes.Leaf) > 0 && IsLeafNode) ||
  268. ((Tree.ShowCheckBoxes & TreeNodeTypes.Parent) > 0 && IsParentNode && Parent != null) ||
  269. ((Tree.ShowCheckBoxes & TreeNodeTypes.Root) > 0 && Parent == null && ChildNodes.Count > 0);
  270. }
  271. }
  272. [DefaultValue ("")]
  273. public string Target {
  274. get {
  275. object o = ViewState ["Target"];
  276. if(o != null) return (string)o;
  277. return "";
  278. }
  279. set {
  280. ViewState ["Target"] = value;
  281. }
  282. }
  283. [Localizable (true)]
  284. [DefaultValue ("")]
  285. [WebSysDescription ("The display text of the tree node.")]
  286. public string Text {
  287. get {
  288. object o = ViewState ["Text"];
  289. if (o == null)
  290. o = ViewState ["Value"];
  291. if (o != null) return (string)o;
  292. return String.Empty;
  293. }
  294. set {
  295. ViewState ["Text"] = value;
  296. }
  297. }
  298. [Localizable (true)]
  299. [DefaultValue ("")]
  300. public string ToolTip {
  301. get {
  302. object o = ViewState ["ToolTip"];
  303. if(o != null) return (string)o;
  304. return "";
  305. }
  306. set {
  307. ViewState ["ToolTip"] = value;
  308. }
  309. }
  310. [Localizable (true)]
  311. [DefaultValue ("")]
  312. public string Value {
  313. get {
  314. object o = ViewState ["Value"];
  315. if (o == null)
  316. o = ViewState ["Text"];
  317. if(o != null) return (string)o;
  318. return String.Empty;
  319. }
  320. set {
  321. ViewState ["Value"] = value;
  322. }
  323. }
  324. [DefaultValue (false)]
  325. public bool Selected {
  326. get {
  327. return SelectedFlag;
  328. }
  329. set {
  330. SelectedFlag = value;
  331. if (tree != null) {
  332. if (!value && tree.SelectedNode == this)
  333. tree.SetSelectedNode (null, false);
  334. else if (value)
  335. tree.SetSelectedNode (this, false);
  336. }
  337. }
  338. }
  339. internal virtual bool SelectedFlag {
  340. get {
  341. object o = ViewState ["Selected"];
  342. if(o != null) return (bool)o;
  343. return false;
  344. }
  345. set {
  346. ViewState ["Selected"] = value;
  347. }
  348. }
  349. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  350. [Browsable (false)]
  351. public TreeNode Parent {
  352. get { return parent; }
  353. }
  354. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  355. [Browsable (false)]
  356. public string ValuePath {
  357. get {
  358. if (tree == null) return Value;
  359. StringBuilder sb = new StringBuilder (Value);
  360. TreeNode node = parent;
  361. while (node != null) {
  362. sb.Insert (0, tree.PathSeparator);
  363. sb.Insert (0, node.Value);
  364. node = node.Parent;
  365. }
  366. return sb.ToString ();
  367. }
  368. }
  369. internal int Index {
  370. get { return index; }
  371. set { index = value; ResetPathData (); }
  372. }
  373. internal void SetParent (TreeNode node) {
  374. parent = node;
  375. ResetPathData ();
  376. }
  377. internal string Path {
  378. get {
  379. if (path != null) return path;
  380. StringBuilder sb = new StringBuilder (index.ToString());
  381. TreeNode node = parent;
  382. while (node != null) {
  383. sb.Insert (0, '_');
  384. sb.Insert (0, node.Index.ToString ());
  385. node = node.Parent;
  386. }
  387. path = sb.ToString ();
  388. return path;
  389. }
  390. }
  391. internal bool Populated {
  392. get {
  393. object o = ViewState ["Populated"];
  394. if (o != null) return (bool) o;
  395. return false;
  396. }
  397. set {
  398. ViewState ["Populated"] = value;
  399. }
  400. }
  401. internal bool HasChildData {
  402. get { return nodes != null; }
  403. }
  404. internal void Populate ()
  405. {
  406. if (tree == null)
  407. return;
  408. Populated = true;
  409. tree.NotifyPopulateRequired (this);
  410. }
  411. public void Collapse ()
  412. {
  413. Expanded = false;
  414. }
  415. public void CollapseAll ()
  416. {
  417. SetExpandedRec (false, -1);
  418. }
  419. public void Expand ()
  420. {
  421. Expanded = true;
  422. }
  423. internal void Expand (int depth)
  424. {
  425. SetExpandedRec (true, depth);
  426. }
  427. public void ExpandAll ()
  428. {
  429. SetExpandedRec (true, -1);
  430. }
  431. void SetExpandedRec (bool expanded, int depth)
  432. {
  433. Expanded = expanded;
  434. if (depth == 0) return;
  435. foreach (TreeNode nod in ChildNodes)
  436. nod.SetExpandedRec (expanded, depth - 1);
  437. }
  438. public void Select ()
  439. {
  440. Selected = true;
  441. }
  442. public void ToggleExpandState ()
  443. {
  444. #if TARGET_JVM //No support for Nullable<bool>.GetValueOrDefault() yet
  445. bool? value = Expanded;
  446. Expanded = value.HasValue ? !value.Value : true;
  447. #else
  448. Expanded = !Expanded.GetValueOrDefault(false);
  449. #endif
  450. }
  451. void IStateManager.LoadViewState (object savedState)
  452. {
  453. LoadViewState (savedState);
  454. }
  455. protected virtual void LoadViewState (object savedState)
  456. {
  457. if (savedState == null)
  458. return;
  459. object[] states = (object[]) savedState;
  460. ViewState.LoadViewState (states [0]);
  461. if (tree != null && SelectedFlag)
  462. tree.SetSelectedNode (this, true);
  463. if (!PopulateOnDemand || Populated)
  464. ((IStateManager)ChildNodes).LoadViewState (states [1]);
  465. }
  466. object IStateManager.SaveViewState ()
  467. {
  468. return SaveViewState ();
  469. }
  470. protected virtual object SaveViewState ()
  471. {
  472. object[] states = new object[2];
  473. states[0] = ViewState.SaveViewState();
  474. states[1] = (nodes == null ? null : ((IStateManager)nodes).SaveViewState());
  475. for (int i = 0; i < states.Length; i++) {
  476. if (states [i] != null)
  477. return states;
  478. }
  479. return null;
  480. }
  481. void IStateManager.TrackViewState ()
  482. {
  483. TrackViewState ();
  484. }
  485. protected void TrackViewState ()
  486. {
  487. if (marked) return;
  488. marked = true;
  489. ViewState.TrackViewState();
  490. if (nodes != null)
  491. ((IStateManager)nodes).TrackViewState ();
  492. }
  493. bool IStateManager.IsTrackingViewState {
  494. get { return IsTrackingViewState; }
  495. }
  496. protected bool IsTrackingViewState
  497. {
  498. get { return marked; }
  499. }
  500. internal void SetDirty ()
  501. {
  502. ViewState.SetDirty (true);
  503. if (nodes != null)
  504. nodes.SetDirty ();
  505. }
  506. public virtual object Clone ()
  507. {
  508. TreeNode nod = tree != null ? tree.CreateNode () : new TreeNode ();
  509. foreach (DictionaryEntry e in ViewState)
  510. nod.ViewState [(string)e.Key] = ((StateItem)e.Value).Value;
  511. foreach (TreeNode c in ChildNodes)
  512. nod.ChildNodes.Add ((TreeNode)c.Clone ());
  513. return nod;
  514. }
  515. object ICloneable.Clone () {
  516. return Clone ();
  517. }
  518. internal void Bind (IHierarchyData hierarchyData)
  519. {
  520. this.hierarchyData = hierarchyData;
  521. DataBound = true;
  522. DataPath = hierarchyData.Path;
  523. dataItem = hierarchyData.Item;
  524. TreeNodeBinding bin = GetBinding ();
  525. if (bin != null) {
  526. // Bind ImageToolTip property
  527. if (bin.ImageToolTipField.Length > 0) {
  528. ImageToolTip = Convert.ToString (GetBoundPropertyValue (bin.ImageToolTipField));
  529. if (ImageToolTip.Length == 0)
  530. ImageToolTip = bin.ImageToolTip;
  531. }
  532. else if (bin.ImageToolTip.Length > 0)
  533. ImageToolTip = bin.ImageToolTip;
  534. // Bind ImageUrl property
  535. if (bin.ImageUrlField.Length > 0) {
  536. ImageUrl = Convert.ToString (GetBoundPropertyValue (bin.ImageUrlField));
  537. if (ImageUrl.Length == 0)
  538. ImageUrl = bin.ImageUrl;
  539. }
  540. else if (bin.ImageUrl.Length > 0)
  541. ImageUrl = bin.ImageUrl;
  542. // Bind NavigateUrl property
  543. if (bin.NavigateUrlField.Length > 0) {
  544. NavigateUrl = Convert.ToString (GetBoundPropertyValue (bin.NavigateUrlField));
  545. if (NavigateUrl.Length == 0)
  546. NavigateUrl = bin.NavigateUrl;
  547. }
  548. else if (bin.NavigateUrl.Length > 0)
  549. NavigateUrl = bin.NavigateUrl;
  550. // Bind PopulateOnDemand property
  551. if (bin.HasPropertyValue ("PopulateOnDemand"))
  552. PopulateOnDemand = bin.PopulateOnDemand;
  553. // Bind SelectAction property
  554. if (bin.HasPropertyValue ("SelectAction"))
  555. SelectAction = bin.SelectAction;
  556. // Bind ShowCheckBox property
  557. if (bin.HasPropertyValue ("ShowCheckBox"))
  558. ShowCheckBox = bin.ShowCheckBox;
  559. // Bind Target property
  560. if (bin.TargetField.Length > 0) {
  561. Target = Convert.ToString (GetBoundPropertyValue (bin.TargetField));
  562. if (Target.Length == 0)
  563. Target = bin.Target;
  564. }
  565. else if (bin.Target.Length > 0)
  566. Target = bin.Target;
  567. // Bind Text property
  568. string text = null;
  569. if (bin.TextField.Length > 0) {
  570. text = Convert.ToString (GetBoundPropertyValue (bin.TextField));
  571. if (bin.FormatString.Length > 0)
  572. text = string.Format (bin.FormatString, text);
  573. }
  574. if (String.IsNullOrEmpty (text)) {
  575. if (bin.Text.Length > 0)
  576. text = bin.Text;
  577. else if (bin.Value.Length > 0)
  578. text = bin.Value;
  579. }
  580. if (!String.IsNullOrEmpty (text))
  581. Text = text;
  582. // Bind ToolTip property
  583. if (bin.ToolTipField.Length > 0) {
  584. ToolTip = Convert.ToString (GetBoundPropertyValue (bin.ToolTipField));
  585. if (ToolTip.Length == 0)
  586. ToolTip = bin.ToolTip;
  587. }
  588. else if (bin.ToolTip.Length > 0)
  589. ToolTip = bin.ToolTip;
  590. // Bind Value property
  591. string value = null;
  592. if (bin.ValueField.Length > 0) {
  593. value = Convert.ToString (GetBoundPropertyValue (bin.ValueField));
  594. }
  595. if (String.IsNullOrEmpty (value)) {
  596. if (bin.Value.Length > 0)
  597. value = bin.Value;
  598. else if (bin.Text.Length > 0)
  599. value = bin.Text;
  600. }
  601. if (!String.IsNullOrEmpty (value))
  602. Value = value;
  603. }
  604. else {
  605. Text = Value = GetDefaultBoundText ();
  606. }
  607. INavigateUIData navigateUIData = hierarchyData as INavigateUIData;
  608. if (navigateUIData != null) {
  609. SelectAction = TreeNodeSelectAction.None;
  610. Text = navigateUIData.ToString ();
  611. NavigateUrl = navigateUIData.NavigateUrl;
  612. ToolTip = navigateUIData.Description;
  613. }
  614. }
  615. internal void SetDataItem (object item)
  616. {
  617. dataItem = item;
  618. }
  619. internal void SetDataPath (string path)
  620. {
  621. DataPath = path;
  622. }
  623. internal void SetDataBound (bool bound)
  624. {
  625. DataBound = bound;
  626. }
  627. string GetDefaultBoundText ()
  628. {
  629. if (hierarchyData != null) return hierarchyData.ToString ();
  630. else if (dataItem != null) return dataItem.ToString ();
  631. else return string.Empty;
  632. }
  633. string GetDataItemType ()
  634. {
  635. if (hierarchyData != null) return hierarchyData.Type;
  636. else if (dataItem != null) return dataItem.GetType().ToString ();
  637. else return string.Empty;
  638. }
  639. internal bool IsParentNode {
  640. get { return ChildNodes.Count > 0 || (PopulateOnDemand && !Populated); }
  641. }
  642. internal bool IsLeafNode {
  643. get { return !IsParentNode; }
  644. }
  645. internal bool IsRootNode {
  646. get { return Depth == 0; }
  647. }
  648. TreeNodeBinding GetBinding ()
  649. {
  650. if (tree == null) return null;
  651. if (gotBinding) return binding;
  652. binding = tree.FindBindingForNode (GetDataItemType (), Depth);
  653. gotBinding = true;
  654. return binding;
  655. }
  656. object GetBoundPropertyValue (string name)
  657. {
  658. if (boundProperties == null) {
  659. if (hierarchyData != null)
  660. boundProperties = TypeDescriptor.GetProperties (hierarchyData);
  661. else
  662. boundProperties = TypeDescriptor.GetProperties (dataItem);
  663. }
  664. PropertyDescriptor prop = boundProperties.Find (name, true);
  665. if (prop == null)
  666. throw new InvalidOperationException ("Property '" + name + "' not found in data bound item");
  667. if (hierarchyData != null)
  668. return prop.GetValue (hierarchyData);
  669. else
  670. return prop.GetValue (dataItem);
  671. }
  672. internal void BeginRenderText (HtmlTextWriter writer)
  673. {
  674. RenderPreText (writer);
  675. }
  676. internal void EndRenderText (HtmlTextWriter writer)
  677. {
  678. RenderPostText (writer);
  679. }
  680. protected virtual void RenderPreText (HtmlTextWriter writer)
  681. {
  682. }
  683. protected virtual void RenderPostText (HtmlTextWriter writer)
  684. {
  685. }
  686. }
  687. }
  688. #endif