BoundColumn.cs 2.2 KB

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