BoundColumn.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /**
  2. * Namespace: System.Web.UI.WebControls
  3. * Class: BoundColumn
  4. *
  5. * Author: Gaurav Vaish
  6. * Maintainer: [email protected]
  7. * Contact: <[email protected]>, <[email protected]>
  8. * Implementation: yes
  9. * Status: 60%
  10. *
  11. * (C) Gaurav Vaish (2001)
  12. */
  13. using System;
  14. using System.ComponentModel;
  15. using System.Web;
  16. using System.Web.UI;
  17. namespace System.Web.UI.WebControls
  18. {
  19. public class BoundColumn : DataGridColumn
  20. {
  21. public static readonly string thisExpr = "!";
  22. private string dataField;
  23. private string dataFormatString;
  24. private bool readOnly;
  25. private PropertyDescriptor desc;
  26. public BoundColumn(): base()
  27. {
  28. //TODO: The start work
  29. Initialize();
  30. }
  31. public override void Initialize()
  32. {
  33. base.Initialize();
  34. dataField = String.Empty;
  35. dataFormatString = String.Empty;
  36. readOnly = false;
  37. desc = null;
  38. }
  39. public override void InitializeCell(TableCell cell, int columnIndex, ListItemType itemType)
  40. {
  41. //TODO: What to do?
  42. base.InitializeCell(cell, columnIndex, itemType);
  43. switch(itemType)
  44. {
  45. case
  46. }
  47. throw new NotImplementedException();
  48. }
  49. public virtual string DataField
  50. {
  51. get
  52. {
  53. return dataField;
  54. }
  55. set
  56. {
  57. dataField = value;
  58. }
  59. }
  60. public virtual string DataFormatString
  61. {
  62. get
  63. {
  64. return dataFormatString;
  65. }
  66. set
  67. {
  68. dataFormatString = value;
  69. }
  70. }
  71. public virtual bool ReadOnly
  72. {
  73. get
  74. {
  75. return readOnly;
  76. }
  77. set
  78. {
  79. readOnly = value;
  80. }
  81. }
  82. protected virtual string FormatDataValue(Object dataValue)
  83. {
  84. // TODO: How to extract the value from the object?
  85. // TODO: Then format the value. Here's a possible solution
  86. if(dataFormatString == null || dataFormatString.equals(String.Empty))
  87. return dataValue.toString();
  88. if(dataValue is DateTime)
  89. return ((DateTime)dataValue).toString(dataFormatString);
  90. throw new NotImplementedException();
  91. // and so on for int, String, double..
  92. // something's wrong here. there must be some shorter method!
  93. //string val = dataValue.toString(dataFormatString);
  94. }
  95. }
  96. }