BoundColumn.cs 1.8 KB

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