BaseDataList.cs 3.2 KB

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