2
0

BaseDataList.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /**
  2. * Namespace: System.Web.UI.WebControls
  3. * Class: BaseDataList
  4. *
  5. * Author: Gaurav Vaish
  6. * Maintainer: [email protected]
  7. * Contact: <[email protected]>, <[email protected]>
  8. * Implementation: yes
  9. * Status: 20%
  10. *
  11. * (C) Gaurav Vaish (2001)
  12. */
  13. using System;
  14. using System.Collections;
  15. using System.Web;
  16. using System.Web.UI;
  17. namespace System.Web.UI.WebControls
  18. {
  19. public abstract class BaseDataList: WebControl
  20. {
  21. private int cellPadding = -1;
  22. private int cellSpacing = 0;
  23. private object dataSource = null;
  24. private string dataKeyField = String.Empty;
  25. private DataKeyCollection dataKeys; // TODO: From where do get the values into it?
  26. private string dataMember;
  27. private GridLines gridLines;
  28. private HorizontalAlign hAlign;
  29. public BaseDataList()
  30. {
  31. // TODO Something
  32. dataKeys = new DataKeyCollection(new ArrayList());
  33. dataMember = String.Empty;
  34. gridLines = GridLines.Both;
  35. hAlign = HorizontalAlign.NotSet;
  36. }
  37. public static bool IsBindableType(Type type)
  38. {
  39. //TODO: To see what has to be here
  40. if(type.IsPrimitive)
  41. {
  42. //Type.GetTypeFromHandle(new RuntimeTypeHandle());
  43. }
  44. return false; //for the time being, to be able to make it compile
  45. }
  46. public virtual int CellPadding
  47. {
  48. get
  49. {
  50. return cellPadding;
  51. }
  52. set
  53. {
  54. cellPadding = value;
  55. }
  56. }
  57. public virtual int CellSpacing
  58. {
  59. get
  60. {
  61. return cellSpacing;
  62. }
  63. set
  64. {
  65. cellSpacing = value;
  66. }
  67. }
  68. public virtual string DataKeyField
  69. {
  70. get
  71. {
  72. return dataKeyField;
  73. }
  74. set
  75. {
  76. dataKeyField = value;
  77. }
  78. }
  79. public DataKeyCollection DataKeys
  80. {
  81. get
  82. {
  83. return dataKeys;
  84. }
  85. }
  86. public string DataMember
  87. {
  88. get
  89. {
  90. return dataMember;
  91. }
  92. set
  93. {
  94. dataMember = value;
  95. }
  96. }
  97. public virtual object DataSource
  98. {
  99. get
  100. {
  101. return dataSource;
  102. }
  103. set
  104. {
  105. dataSource = value;
  106. }
  107. }
  108. public virtual GridLines GridLines
  109. {
  110. get
  111. {
  112. return gridLines;
  113. }
  114. set
  115. {
  116. gridLines = value;
  117. }
  118. }
  119. public virtual HorizontalAlign HorizontalAlign
  120. {
  121. get
  122. {
  123. return hAlign;
  124. }
  125. set
  126. {
  127. hAlign = value;
  128. }
  129. }
  130. public override void DataBind()
  131. {
  132. // TODO: have to write the implementation
  133. // I am not sure of whether it will be of any use here since
  134. // I am an abstract class, and have no identity of myself.
  135. //dataBindEventArgs = EventArgs.Empty;
  136. OnDataBinding(EventArgs.Empty);
  137. throw new NotImplementedException();
  138. }
  139. //TODO: Check - where are the following abstract methods?
  140. /*
  141. * CreateControlHierarchy(bool)
  142. * PrepareControlHierarchy()
  143. */
  144. protected override void AddParsedSubObject(object o)
  145. {
  146. // Preventing literal controls from being added as children: Do nothing here.
  147. }
  148. protected override void CreateChildControls()
  149. {
  150. Controls.Clear();
  151. if(ViewState["_!ItemCount"]!=null)
  152. {
  153. CreateControlHierarchy(true);
  154. ClearChildViewState();
  155. }
  156. }
  157. protected abstract void CreateControlHierarchy(bool useDataSource);
  158. }
  159. }