Composite control problem !!!!

Discussion in 'ASP .Net Web Controls' started by Mircea Pleteriu, Jun 25, 2004.

  1. Hi all,

    I have a composite control which only consists in a datagrid control for
    beginning.

    I create the datagrid control within the EnsureChildControls method and set
    the AutoGeneratedColumns to false

    My control exposes a method AddColumn(DataColumn column) which adds the
    specified column to the
    datagrid's columns collection.

    My control also exposes a property named DataSource which exposes the
    datagrid's DataSource property.

    So, the user is able to add columns and set the datasource.

    I override the DataBind method of the control
    Inside the method I create a new template column consisting in a CheckBox
    control and add it as the first column of the datagrid.
    After that I call the DataBind on the daragrid control.

    That's all about the custom control.

    Now about the page that hosts the control.

    The page only consits in my custom control and a button which when it is
    pressed it should write to the output stream the indexes of the checked
    items (the fist column being a checkbox).

    In the Page_Load method I create more columns of type BoundColumn and add
    them to the custom control. Also, I set the DataSource to point to a filled
    in DataSet object after which I invoke the DataBind on my custom control.

    Everything is fine.. the grid is displayed and the user can check items in
    the grid.

    When the button on the page is pressed I invoke a method of my control which
    ensures that the controls exists calling EnsureChildControls and then
    iterates through
    the items of the grid and make a list of the checked items.

    The BIG PROBLEM is that the collection of items is always EMPTY !!!!!

    Do you have any idea why? Do you know any other solution to get the checked
    items?

    Thanks for help,
    Mircea
     
    Mircea Pleteriu, Jun 25, 2004
    #1
    1. Advertising

  2. Mircea Pleteriu

    Teemu Keiski Guest

    Hi,

    post the relevant code of your control and page. That way it is easier for
    us to figure out what you have done so far.

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist
    http://blogs.aspadvice.com/joteke


    "Mircea Pleteriu" <> wrote in message
    news:...
    > Hi all,
    >
    > I have a composite control which only consists in a datagrid control for
    > beginning.
    >
    > I create the datagrid control within the EnsureChildControls method and

    set
    > the AutoGeneratedColumns to false
    >
    > My control exposes a method AddColumn(DataColumn column) which adds the
    > specified column to the
    > datagrid's columns collection.
    >
    > My control also exposes a property named DataSource which exposes the
    > datagrid's DataSource property.
    >
    > So, the user is able to add columns and set the datasource.
    >
    > I override the DataBind method of the control
    > Inside the method I create a new template column consisting in a CheckBox
    > control and add it as the first column of the datagrid.
    > After that I call the DataBind on the daragrid control.
    >
    > That's all about the custom control.
    >
    > Now about the page that hosts the control.
    >
    > The page only consits in my custom control and a button which when it is
    > pressed it should write to the output stream the indexes of the checked
    > items (the fist column being a checkbox).
    >
    > In the Page_Load method I create more columns of type BoundColumn and add
    > them to the custom control. Also, I set the DataSource to point to a

    filled
    > in DataSet object after which I invoke the DataBind on my custom control.
    >
    > Everything is fine.. the grid is displayed and the user can check items in
    > the grid.
    >
    > When the button on the page is pressed I invoke a method of my control

    which
    > ensures that the controls exists calling EnsureChildControls and then
    > iterates through
    > the items of the grid and make a list of the checked items.
    >
    > The BIG PROBLEM is that the collection of items is always EMPTY !!!!!
    >
    > Do you have any idea why? Do you know any other solution to get the

    checked
    > items?
    >
    > Thanks for help,
    > Mircea
    >
    >
    >
    >
    >
    >
    >
    >
    >
     
    Teemu Keiski, Jun 25, 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. Replies:
    0
    Views:
    723
  2. sleigh
    Replies:
    1
    Views:
    2,694
    sleigh
    Feb 12, 2004
  3. shapper
    Replies:
    6
    Views:
    958
    shapper
    Dec 26, 2007
  4. Chad
    Replies:
    0
    Views:
    225
  5. Mike

    Composite vs non composite Controls

    Mike, Mar 10, 2005, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    266
    Sundararajan
    Mar 11, 2005
Loading...

Share This Page