BaseDataList.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. * Status: 20%
  9. *
  10. * (C) Gaurav Vaish (2001)
  11. */
  12. using System;
  13. using System.Collections;
  14. using System.Web;
  15. using System.Web.UI;
  16. namespace System.Web.UI.WebControls
  17. {
  18. public abstract class BaseDataList: WebControl
  19. {
  20. private int cellPadding = -1;
  21. private int cellSpacing = 0;
  22. private object dataSource = null;
  23. private string dataKeyField = String.Empty;
  24. private DataKeyCollection dataKeys; // TODO: From where do get the values into it?
  25. private string dataMember;
  26. private GridLines gridLines;
  27. private HorizontalAlign hAlign;
  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. throw new NotImplementedException();
  137. }
  138. //TODO: Check - where are the following abstract methods?
  139. /*
  140. * CreateControlHierarchy(bool)
  141. * PrepareControlHierarchy()
  142. */
  143. protected override void AddParsedSubObject(object o)
  144. {
  145. // Preventing literal controls from being added as children: Do nothing here.
  146. }
  147. protected override void CreateChildControls()
  148. {
  149. Controls.Clear();
  150. if(ViewState["_!ItemCount"]!=null)
  151. {
  152. CreateControlHierarchy(true);
  153. ClearChildViewState();
  154. }
  155. }
  156. protected abstract void CreateControlHierarchy(bool useDataSource);
  157. }
  158. }