Critique Request: CheckBoxColumn

Discussion in 'ASP .Net' started by Fao, Sean, Feb 15, 2006.

  1. Fao, Sean

    Fao, Sean Guest

    I recently had the desire to create a CheckBoxColumn (similar to a
    ButtonColumn) that I could add to a DataGrid. I believe the 2.0
    framework already includes such a type; however, this is for an ASP.NET
    1.1 project.

    Could anybody please give me some feedback on my implementation?

    <code>
    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.ComponentModel;

    namespace MyProject.Controls
    {
    /// <summary>
    /// Summary description for CheckBoxColumn.
    /// </summary>
    public class CheckBoxColumn : DataGridColumn, INamingContainer
    {
    private bool _checked; /// Determines whether CheckBox
    /// in CheckBoxColumn is checked
    private bool _enableviwestate; /// Determines whether object
    /// persists its ViewState
    private string _id; /// The unique identifier for the
    /// control

    /// <summary>
    /// Gets or sets a value that determines whether the
    /// CheckBoxColumn is checked
    /// </summary>
    [DefaultValue(false), Description("CheckBox_Checked"),
    Bindable(true)]
    public bool Checked
    {
    get
    {
    return this._checked;
    }
    set
    {
    this._checked = value;
    }
    }

    /// <summary>
    /// Gets or sets a value indicating whether object persists its
    /// ViewState
    /// </summary>
    [Description("Control_MaintainState"), DefaultValue(true),
    Category("Behavior")]
    public bool EnableViewState
    {
    get
    {
    return this._enableviwestate;
    }
    set
    {
    this._enableviwestate = value;
    }
    }

    /// <summary>
    /// Gets or sets the unique identifier of the CheckBoxColumn
    /// </summary>
    [MergableProperty(false), ParenthesizePropertyName(true),
    Description("Control_ID")]
    public string ID
    {
    get
    {
    return this._id;
    }
    set
    {
    this._id = value;
    }
    }

    /// <summary>
    /// Creates an instance of a CheckBoxColumn
    /// </summary>
    public CheckBoxColumn()
    {
    }

    /// <summary>
    /// Implements base method to reset the specified cell to its
    /// initial value
    /// </summary>
    /// <param name="cell">A System.Web.UI.WebControls.TableCell
    /// that represents the cell to reset</param>
    /// <param name="columnIndex">Resets the specified cell to its
    /// initial value</param>
    /// <param name="itemType">Resets the specified cell to its
    /// initial value</param>
    public override void InitializeCell(TableCell cell, int
    columnIndex, ListItemType itemType)
    {
    base.InitializeCell (cell, columnIndex, itemType);

    if ((itemType != ListItemType.Header) && (itemType !=
    ListItemType.Footer))
    {
    CheckBox checkbox = new CheckBox();

    checkbox.Checked = this._checked;
    checkbox.EnableViewState = this._enableviwestate;
    checkbox.ID = this._id;

    cell.Controls.Add(checkbox);
    }
    }
    }
    }
    </code>

    I had to manually replace tabs with spaces so I hope that turned out
    alright.

    Thank you in advance,

    --
    Sean
     
    Fao, Sean, Feb 15, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cynthia Turcotte

    critique request

    Cynthia Turcotte, Sep 12, 2003, in forum: HTML
    Replies:
    7
    Views:
    478
    Chris Leonard
    Sep 13, 2003
  2. Andrew Cameron

    Critique request: x01

    Andrew Cameron, Sep 14, 2003, in forum: HTML
    Replies:
    53
    Views:
    1,367
    picayunish
    Sep 17, 2003
  3. rossz
    Replies:
    31
    Views:
    1,026
    Rincewind
    Sep 25, 2005
  4. Alex Chernavsky

    Request for critique of on-line slideshow

    Alex Chernavsky, Oct 11, 2005, in forum: HTML
    Replies:
    5
    Views:
    418
    dorayme
    Oct 12, 2005
  5. sagejoshua
    Replies:
    32
    Views:
    968
    kchayka
    Oct 28, 2005
Loading...

Share This Page