DataGrid Custom Column Error when DataBinding "does not contain a definition for 'DataBinding'"

Discussion in 'ASP .Net Datagrid Control' started by Earl Teigrob, Jan 30, 2004.

  1. Earl Teigrob

    Earl Teigrob Guest

    I am creating a custom column that inherits from DataColumnGrid. When I
    attempt Databind to a property of the custom column, I get the the error:

    CS0117: 'DownloadManager3.CustomBuittonOrText2' does not contain a
    definition for 'DataBinding'

    Is there some interface I need to impliment or something I need to override
    to get databinding working???

    Thanks for your help

    Earl

    The DataGrid code is:

    <cc:CustomBuittonOrText2 ShowButton='<%#
    csCommonLibrary.Common.IsStringEmpty(DataBinder.Eval(Container.DataItem,"Dow
    nloadDate")) %>' Text="Download" AltText="Done" HeaderText="Download"
    Visible="True" CommandName="Download" />



    and the custom column code is:

    (BTW, I know that the databinding event handler does not do anything...yet)


    using System;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;


    namespace DownloadManager3
    {
    /// <summary>
    /// Summary description for CustomBuittonOrText.
    /// </summary>
    public class CustomBuittonOrText2:System.Web.UI.WebControls.DataGridColumn
    {
    public CustomBuittonOrText2()
    {
    //
    // TODO: Add constructor logic here
    //
    }

    public override void InitializeCell(TableCell cell, int columnIndex,
    ListItemType itemType)
    {

    base.InitializeCell (cell, columnIndex, itemType);

    if
    ((itemType==ListItemType.AlternatingItem)||(itemType==ListItemType.Item))
    {
    System.Web.UI.WebControls.Button b = new Button();
    b.Text = this._Text;
    b.Visible=_ShowButton;
    b.CommandName=_CommandName;
    cell.Controls.Add(b);

    System.Web.UI.WebControls.Label l = new
    System.Web.UI.WebControls.Label();
    l.Text=_AltText;
    l.Visible=!_ShowButton;
    cell.Controls.Add(l);

    cell.DataBinding +=new EventHandler(cell_DataBinding);
    }

    }

    public void cell_DataBinding(object sender, EventArgs e)
    {


    }



    private bool _ShowButton=true;
    public bool ShowButton
    {
    get
    {
    return _ShowButton;
    }
    set
    {
    _ShowButton=value;
    }
    }

    private string _AltText="";
    public string AltText
    {
    get
    {
    return _AltText;
    }
    set
    {
    _AltText=value;
    }
    }

    private string _Text="";
    public string Text
    {
    get
    {
    return _Text;
    }
    set
    {
    _Text=value;
    }
    }

    private string _CommandName=String.Empty;
    public string CommandName
    {
    get
    {
    return _CommandName;
    }
    set
    {
    _CommandName=value;
    }
    }

    }
    }
    Earl Teigrob, Jan 30, 2004
    #1
    1. Advertising

  2. Earl Teigrob

    Shravan Guest

    Hi Teigrob,
    I too am suffering from the same problem you were encountering,
    can you suggest me any solution if you have found one.
    In my case I am writing a custom combobox column in a fully
    editable grid(where in every row every column would be editable by a
    control).

    <CustCol:ComboBoxColumn HeaderText="Designation" DataField="DesignId"
    ComboDataSource='<%# GetDesignations() %>'
    ComboTextField="Designation" ComboValueField="DesignId"
    ColumnWidth=100 />

    My code for declaring that column in the grid is as above.
    the attribute declaration
    ComboDataSource='<%# GetDesignations() %>'
    is throwing the
    ERROR "'GridCustomColumns.ComboBoxColumn' does not contain a
    definition for 'DataBinding'"
    Can you please help me out if you have a found a solution.
    Thanks,
    Shravan.

    "Earl Teigrob" <> wrote in message news:<>...
    > I am creating a custom column that inherits from DataColumnGrid. When I
    > attempt Databind to a property of the custom column, I get the the error:
    >
    > CS0117: 'DownloadManager3.CustomBuittonOrText2' does not contain a
    > definition for 'DataBinding'
    >
    > Is there some interface I need to impliment or something I need to override
    > to get databinding working???
    >
    > Thanks for your help
    >
    > Earl
    >
    > The DataGrid code is:
    >
    > <cc:CustomBuittonOrText2 ShowButton='<%#
    > csCommonLibrary.Common.IsStringEmpty(DataBinder.Eval(Container.DataItem,"Dow
    > nloadDate")) %>' Text="Download" AltText="Done" HeaderText="Download"
    > Visible="True" CommandName="Download" />
    >
    >
    >
    > and the custom column code is:
    >
    > (BTW, I know that the databinding event handler does not do anything...yet)
    >
    >
    > using System;
    > using System.Web;
    > using System.Web.UI;
    > using System.Web.UI.WebControls;
    >
    >
    > namespace DownloadManager3
    > {
    > /// <summary>
    > /// Summary description for CustomBuittonOrText.
    > /// </summary>
    > public class CustomBuittonOrText2:System.Web.UI.WebControls.DataGridColumn
    > {
    > public CustomBuittonOrText2()
    > {
    > //
    > // TODO: Add constructor logic here
    > //
    > }
    >
    > public override void InitializeCell(TableCell cell, int columnIndex,
    > ListItemType itemType)
    > {
    >
    > base.InitializeCell (cell, columnIndex, itemType);
    >
    > if
    > ((itemType==ListItemType.AlternatingItem)||(itemType==ListItemType.Item))
    > {
    > System.Web.UI.WebControls.Button b = new Button();
    > b.Text = this._Text;
    > b.Visible=_ShowButton;
    > b.CommandName=_CommandName;
    > cell.Controls.Add(b);
    >
    > System.Web.UI.WebControls.Label l = new
    > System.Web.UI.WebControls.Label();
    > l.Text=_AltText;
    > l.Visible=!_ShowButton;
    > cell.Controls.Add(l);
    >
    > cell.DataBinding +=new EventHandler(cell_DataBinding);
    > }
    >
    > }
    >
    > public void cell_DataBinding(object sender, EventArgs e)
    > {
    >
    >
    > }
    >
    >
    >
    > private bool _ShowButton=true;
    > public bool ShowButton
    > {
    > get
    > {
    > return _ShowButton;
    > }
    > set
    > {
    > _ShowButton=value;
    > }
    > }
    >
    > private string _AltText="";
    > public string AltText
    > {
    > get
    > {
    > return _AltText;
    > }
    > set
    > {
    > _AltText=value;
    > }
    > }
    >
    > private string _Text="";
    > public string Text
    > {
    > get
    > {
    > return _Text;
    > }
    > set
    > {
    > _Text=value;
    > }
    > }
    >
    > private string _CommandName=String.Empty;
    > public string CommandName
    > {
    > get
    > {
    > return _CommandName;
    > }
    > set
    > {
    > _CommandName=value;
    > }
    > }
    >
    > }
    > }
    Shravan, Mar 1, 2004
    #2
    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. Jim Hammond
    Replies:
    1
    Views:
    3,601
    bruce barker
    Nov 26, 2003
  2. Hai Nguyen
    Replies:
    0
    Views:
    392
    Hai Nguyen
    Jan 16, 2004
  3. =?Utf-8?B?SW1hciBTcGFhbmphYXJz?=

    Databinding to custom properties of a custom class in ASP.NET 2

    =?Utf-8?B?SW1hciBTcGFhbmphYXJz?=, Apr 20, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    579
    =?Utf-8?B?SW1hciBTcGFhbmphYXJz?=
    Apr 20, 2005
  4. Keithb
    Replies:
    2
    Views:
    1,114
  5. Ronald Moolenaar

    BoundColumn does not contain a definition for databinding

    Ronald Moolenaar, Jan 5, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    194
    Ronald Moolenaar
    Jan 7, 2005
Loading...

Share This Page