index.aspx.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. using System;
  2. using System.Collections;
  3. using System.Data;
  4. using System.Web.UI.WebControls;
  5. namespace test
  6. {
  7. public class SimplePage : System.Web.UI.Page
  8. {
  9. protected DataGrid testGrid;
  10. public SimplePage()
  11. {
  12. this.Load += new System.EventHandler(this.Page_Load);
  13. }
  14. private void Page_Load(object o, EventArgs e)
  15. {
  16. IDataReader reader = new DummyReader ();
  17. testGrid.DataSource = reader;
  18. testGrid.DataBind();
  19. }
  20. }
  21. class DummyReader : IDataReader, IEnumerable {
  22. IEnumerator IEnumerable.GetEnumerator ()
  23. {
  24. return new EnumThis ();
  25. }
  26. class EnumThis : IEnumerator {
  27. public bool MoveNext ()
  28. {
  29. return false;
  30. }
  31. public void Reset ()
  32. {
  33. }
  34. public object Current {
  35. get { return null; }
  36. }
  37. }
  38. public void Close ()
  39. {
  40. Console.WriteLine ("Close");
  41. }
  42. public DataTable GetSchemaTable ()
  43. {
  44. Console.WriteLine ("GetSchemaTable");
  45. return null;
  46. }
  47. public bool NextResult ()
  48. {
  49. Console.WriteLine ("NextResult");
  50. return false;
  51. }
  52. public bool Read ()
  53. {
  54. Console.WriteLine ("Read");
  55. return false;
  56. }
  57. public int Depth {
  58. get {
  59. Console.WriteLine ("Depth");
  60. return 0;
  61. }
  62. }
  63. public bool IsClosed {
  64. get {
  65. Console.WriteLine ("IsClosed");
  66. return false;
  67. }
  68. }
  69. public int RecordsAffected {
  70. get {
  71. Console.WriteLine ("RecordsAffected");
  72. return -1;
  73. }
  74. }
  75. public void Dispose ()
  76. {
  77. Console.WriteLine ("Dispose");
  78. }
  79. public bool GetBoolean(int i)
  80. {
  81. return false;
  82. }
  83. public byte GetByte(int i)
  84. {
  85. return 0;
  86. }
  87. public long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferOffset, int length)
  88. {
  89. return 0;
  90. }
  91. public char GetChar(int i)
  92. {
  93. return 'A';
  94. }
  95. public long GetChars(int i, long fieldOffset, char[] buffer, int bufferOffset, int length)
  96. {
  97. return 0;
  98. }
  99. public IDataReader GetData(int i)
  100. {
  101. return null;
  102. }
  103. public string GetDataTypeName(int i)
  104. {
  105. return null;
  106. }
  107. public DateTime GetDateTime(int i)
  108. {
  109. return DateTime.MinValue;
  110. }
  111. public Decimal GetDecimal(int i)
  112. {
  113. return 0;
  114. }
  115. public double GetDouble(int i)
  116. {
  117. return 0;
  118. }
  119. public Type GetFieldType(int i)
  120. {
  121. return null;
  122. }
  123. public float GetFloat(int i)
  124. {
  125. return 0;
  126. }
  127. public Guid GetGuid(int i)
  128. {
  129. return new Guid ();
  130. }
  131. public short GetInt16(int i)
  132. {
  133. return 0;
  134. }
  135. public int GetInt32(int i)
  136. {
  137. return 0;
  138. }
  139. public long GetInt64(int i)
  140. {
  141. return 0;
  142. }
  143. public string GetName(int i)
  144. {
  145. return null;
  146. }
  147. public int GetOrdinal(string name)
  148. {
  149. return 0;
  150. }
  151. public string GetString(int i)
  152. {
  153. return null;
  154. }
  155. public object GetValue(int i)
  156. {
  157. return null;
  158. }
  159. public int GetValues(object[] values)
  160. {
  161. return 0;
  162. }
  163. public bool IsDBNull(int i)
  164. {
  165. return false;
  166. }
  167. public int FieldCount {
  168. get { return 0; }
  169. }
  170. public object this [string name] {
  171. get { return null; }
  172. }
  173. public object this [int i] {
  174. get { return null; }
  175. }
  176. }
  177. }