Custom control within repeater with custom object binding - .net 1

Discussion in 'ASP .Net' started by =?Utf-8?B?SmF5YnVmZmV0?=, Feb 16, 2006.

  1. my aspx has something like this

    <asp:Repeater id="Repeater1" runat="server">
    <ItemTemplate>
    <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>'
    showItem="true"/>
    </ItemTemplate>
    /asp:Repeater>

    The DataSource for this Repeater is a CollectionBase of objects and is
    assigned and bound on Page_Load.

    Now I have a Calendar control that fires a SelectionChanged. I want that to
    crate a new Collection of objects based on the selected date and rebound.
    However it doesn't seem to keep the Container.DataItem. The control shows a
    null object however the static fields are passed (i.e. the showPass shows
    "true" when debugging).

    What am I doing wrong? Any help would be much appreciated.
     
    =?Utf-8?B?SmF5YnVmZmV0?=, Feb 16, 2006
    #1
    1. Advertising

  2. Let me clarify.. my SelectionChanged method has

    db = new dbHelper();
    Repeater1.DataSource = db.GetObjects();
    Repeater1.DataBind()

    This doesn't work.

    "Jaybuffet" wrote:

    > my aspx has something like this
    >
    > <asp:Repeater id="Repeater1" runat="server">
    > <ItemTemplate>
    > <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>'
    > showItem="true"/>
    > </ItemTemplate>
    > /asp:Repeater>
    >
    > The DataSource for this Repeater is a CollectionBase of objects and is
    > assigned and bound on Page_Load.
    >
    > Now I have a Calendar control that fires a SelectionChanged. I want that to
    > crate a new Collection of objects based on the selected date and rebound.
    > However it doesn't seem to keep the Container.DataItem. The control shows a
    > null object however the static fields are passed (i.e. the showPass shows
    > "true" when debugging).
    >
    > What am I doing wrong? Any help would be much appreciated.
    >
     
    =?Utf-8?B?SmF5YnVmZmV0?=, Feb 16, 2006
    #2
    1. Advertising

  3. I'm new to the newsgroups, do questions get answered usually here or is there
    a more active site i should try posting to?

    Thanks you

    "Jaybuffet" wrote:

    > my aspx has something like this
    >
    > <asp:Repeater id="Repeater1" runat="server">
    > <ItemTemplate>
    > <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>'
    > showItem="true"/>
    > </ItemTemplate>
    > /asp:Repeater>
    >
    > The DataSource for this Repeater is a CollectionBase of objects and is
    > assigned and bound on Page_Load.
    >
    > Now I have a Calendar control that fires a SelectionChanged. I want that to
    > crate a new Collection of objects based on the selected date and rebound.
    > However it doesn't seem to keep the Container.DataItem. The control shows a
    > null object however the static fields are passed (i.e. the showPass shows
    > "true" when debugging).
    >
    > What am I doing wrong? Any help would be much appreciated.
    >
     
    =?Utf-8?B?SmF5YnVmZmV0?=, Feb 16, 2006
    #3
  4. RE: Custom control within repeater with custom object binding - .n

    Questions get answered fairly quickly here. Your question however has a few
    ambiguities:

    1- when you say "However it doesn't seem to keep the Container.DataItem" you
    did not clarify what are you referring to. If you are referring to the
    Calender that is within the RepeaterItem then what method are you using and
    in which event are you attempting to get the DataItem?

    2- when you say "The control shows a null object however the static fields
    are passed (i.e. the showPass shows "true" when debugging)." Which control
    are you referring to that has a null value? What are “static fields"? And
    what is "showPass"? Is "showPass" a customized property of your control?

    --
    HTH,
    Phillip Williams
    http://www.societopia.net
    http://www.webswapp.com


    "Jaybuffet" wrote:

    > I'm new to the newsgroups, do questions get answered usually here or is there
    > a more active site i should try posting to?
    >
    > Thanks you
    >
    > "Jaybuffet" wrote:
    >
    > > my aspx has something like this
    > >
    > > <asp:Repeater id="Repeater1" runat="server">
    > > <ItemTemplate>
    > > <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>'
    > > showItem="true"/>
    > > </ItemTemplate>
    > > /asp:Repeater>
    > >
    > > The DataSource for this Repeater is a CollectionBase of objects and is
    > > assigned and bound on Page_Load.
    > >
    > > Now I have a Calendar control that fires a SelectionChanged. I want that to
    > > crate a new Collection of objects based on the selected date and rebound.
    > > However it doesn't seem to keep the Container.DataItem. The control shows a
    > > null object however the static fields are passed (i.e. the showPass shows
    > > "true" when debugging).
    > >
    > > What am I doing wrong? Any help would be much appreciated.
    > >
     
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=, Feb 16, 2006
    #4
  5. RE: Custom control within repeater with custom object binding

    Not sure if this is correct but this is how i ended up fixing it... don't
    know if its a kludge, but it seems to work.. On initial page load it sets
    the obj property twice however, but oh well.

    in repeater_itemcreated i put if((e.Item.Controls.Count>1) &&
    (e.Item.Controls[1].GetType().Name=="mycontrol.ascx"))
    ((mycontrol)e.Item.Controls[1]).obj = (obj)e.Item.DataItem;

    To answer your questions so maybe i can get a better solution:

    Calendar is elsewhere on the page, not in a repeater. There was a typo, i
    didn't mean "showPass", i meant "showItem", as the code snippet has and yes
    it is a property on my ascx.

    When i debug the property that sets the "obj" and I step through, the
    initial page load works great. I set the repeater datasource to a collection
    of objects then bind. When a breakpoint is set on the set method in the
    "obj" property it is triggered on initial page_load, however, after i select
    a date and then in calendar_selectionchanged i select a different datasource
    (filtered based on the day) and then bind, it never reaches that breakpoint.

    Don't know if i am explaing this correctly, but i am trying.

    Thank you for your help!!

    "Phillip Williams" wrote:

    > Questions get answered fairly quickly here. Your question however has a few
    > ambiguities:
    >
    > 1- when you say "However it doesn't seem to keep the Container.DataItem" you
    > did not clarify what are you referring to. If you are referring to the
    > Calender that is within the RepeaterItem then what method are you using and
    > in which event are you attempting to get the DataItem?
    >
    > 2- when you say "The control shows a null object however the static fields
    > are passed (i.e. the showPass shows "true" when debugging)." Which control
    > are you referring to that has a null value? What are “static fields"? And
    > what is "showPass"? Is "showPass" a customized property of your control?
    >
    > --
    > HTH,
    > Phillip Williams
    > http://www.societopia.net
    > http://www.webswapp.com
    >
    >
    > "Jaybuffet" wrote:
    >
    > > I'm new to the newsgroups, do questions get answered usually here or is there
    > > a more active site i should try posting to?
    > >
    > > Thanks you
    > >
    > > "Jaybuffet" wrote:
    > >
    > > > my aspx has something like this
    > > >
    > > > <asp:Repeater id="Repeater1" runat="server">
    > > > <ItemTemplate>
    > > > <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>'
    > > > showItem="true"/>
    > > > </ItemTemplate>
    > > > /asp:Repeater>
    > > >
    > > > The DataSource for this Repeater is a CollectionBase of objects and is
    > > > assigned and bound on Page_Load.
    > > >
    > > > Now I have a Calendar control that fires a SelectionChanged. I want that to
    > > > crate a new Collection of objects based on the selected date and rebound.
    > > > However it doesn't seem to keep the Container.DataItem. The control shows a
    > > > null object however the static fields are passed (i.e. the showPass shows
    > > > "true" when debugging).
    > > >
    > > > What am I doing wrong? Any help would be much appreciated.
    > > >
     
    =?Utf-8?B?SmF5YnVmZmV0?=, Feb 16, 2006
    #5
  6. RE: Custom control within repeater with custom object binding

    If I create a demo that matches the description that you posted I do not get
    the problem that you got. Here is the demo:
    http://www.webswapp.com/demos/feb162006.aspx

    The problem you got could have happened if you had added your custom control
    to the page programmatically (instead of declaratively as you posted below).

    --
    HTH,
    Phillip Williams
    http://www.societopia.net
    http://www.webswapp.com


    "Jaybuffet" wrote:

    > Not sure if this is correct but this is how i ended up fixing it... don't
    > know if its a kludge, but it seems to work.. On initial page load it sets
    > the obj property twice however, but oh well.
    >
    > in repeater_itemcreated i put if((e.Item.Controls.Count>1) &&
    > (e.Item.Controls[1].GetType().Name=="mycontrol.ascx"))
    > ((mycontrol)e.Item.Controls[1]).obj = (obj)e.Item.DataItem;
    >
    > To answer your questions so maybe i can get a better solution:
    >
    > Calendar is elsewhere on the page, not in a repeater. There was a typo, i
    > didn't mean "showPass", i meant "showItem", as the code snippet has and yes
    > it is a property on my ascx.
    >
    > When i debug the property that sets the "obj" and I step through, the
    > initial page load works great. I set the repeater datasource to a collection
    > of objects then bind. When a breakpoint is set on the set method in the
    > "obj" property it is triggered on initial page_load, however, after i select
    > a date and then in calendar_selectionchanged i select a different datasource
    > (filtered based on the day) and then bind, it never reaches that breakpoint.
    >
    > Don't know if i am explaing this correctly, but i am trying.
    >
    > Thank you for your help!!
    >
    > "Phillip Williams" wrote:
    >
    > > Questions get answered fairly quickly here. Your question however has a few
    > > ambiguities:
    > >
    > > 1- when you say "However it doesn't seem to keep the Container.DataItem" you
    > > did not clarify what are you referring to. If you are referring to the
    > > Calender that is within the RepeaterItem then what method are you using and
    > > in which event are you attempting to get the DataItem?
    > >
    > > 2- when you say "The control shows a null object however the static fields
    > > are passed (i.e. the showPass shows "true" when debugging)." Which control
    > > are you referring to that has a null value? What are “static fields"? And
    > > what is "showPass"? Is "showPass" a customized property of your control?
    > >
    > > --
    > > HTH,
    > > Phillip Williams
    > > http://www.societopia.net
    > > http://www.webswapp.com
    > >
    > >
    > > "Jaybuffet" wrote:
    > >
    > > > I'm new to the newsgroups, do questions get answered usually here or is there
    > > > a more active site i should try posting to?
    > > >
    > > > Thanks you
    > > >
    > > > "Jaybuffet" wrote:
    > > >
    > > > > my aspx has something like this
    > > > >
    > > > > <asp:Repeater id="Repeater1" runat="server">
    > > > > <ItemTemplate>
    > > > > <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>'
    > > > > showItem="true"/>
    > > > > </ItemTemplate>
    > > > > /asp:Repeater>
    > > > >
    > > > > The DataSource for this Repeater is a CollectionBase of objects and is
    > > > > assigned and bound on Page_Load.
    > > > >
    > > > > Now I have a Calendar control that fires a SelectionChanged. I want that to
    > > > > crate a new Collection of objects based on the selected date and rebound.
    > > > > However it doesn't seem to keep the Container.DataItem. The control shows a
    > > > > null object however the static fields are passed (i.e. the showPass shows
    > > > > "true" when debugging).
    > > > >
    > > > > What am I doing wrong? Any help would be much appreciated.
    > > > >
     
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=, Feb 16, 2006
    #6
  7. RE: Custom control within repeater with custom object binding

    Was this im ASP.NET 1.1? It seems like how i have (except the user control,
    I set label values in Page_Load). But that doesn't seem to matter because
    when stepping through i never get to the Set call.

    "Phillip Williams" wrote:

    > If I create a demo that matches the description that you posted I do not get
    > the problem that you got. Here is the demo:
    > http://www.webswapp.com/demos/feb162006.aspx
    >
    > The problem you got could have happened if you had added your custom control
    > to the page programmatically (instead of declaratively as you posted below).
    >
    > --
    > HTH,
    > Phillip Williams
    > http://www.societopia.net
    > http://www.webswapp.com
    >
    >
    > "Jaybuffet" wrote:
    >
    > > Not sure if this is correct but this is how i ended up fixing it... don't
    > > know if its a kludge, but it seems to work.. On initial page load it sets
    > > the obj property twice however, but oh well.
    > >
    > > in repeater_itemcreated i put if((e.Item.Controls.Count>1) &&
    > > (e.Item.Controls[1].GetType().Name=="mycontrol.ascx"))
    > > ((mycontrol)e.Item.Controls[1]).obj = (obj)e.Item.DataItem;
    > >
    > > To answer your questions so maybe i can get a better solution:
    > >
    > > Calendar is elsewhere on the page, not in a repeater. There was a typo, i
    > > didn't mean "showPass", i meant "showItem", as the code snippet has and yes
    > > it is a property on my ascx.
    > >
    > > When i debug the property that sets the "obj" and I step through, the
    > > initial page load works great. I set the repeater datasource to a collection
    > > of objects then bind. When a breakpoint is set on the set method in the
    > > "obj" property it is triggered on initial page_load, however, after i select
    > > a date and then in calendar_selectionchanged i select a different datasource
    > > (filtered based on the day) and then bind, it never reaches that breakpoint.
    > >
    > > Don't know if i am explaing this correctly, but i am trying.
    > >
    > > Thank you for your help!!
    > >
    > > "Phillip Williams" wrote:
    > >
    > > > Questions get answered fairly quickly here. Your question however has a few
    > > > ambiguities:
    > > >
    > > > 1- when you say "However it doesn't seem to keep the Container.DataItem" you
    > > > did not clarify what are you referring to. If you are referring to the
    > > > Calender that is within the RepeaterItem then what method are you using and
    > > > in which event are you attempting to get the DataItem?
    > > >
    > > > 2- when you say "The control shows a null object however the static fields
    > > > are passed (i.e. the showPass shows "true" when debugging)." Which control
    > > > are you referring to that has a null value? What are “static fields"? And
    > > > what is "showPass"? Is "showPass" a customized property of your control?
    > > >
    > > > --
    > > > HTH,
    > > > Phillip Williams
    > > > http://www.societopia.net
    > > > http://www.webswapp.com
    > > >
    > > >
    > > > "Jaybuffet" wrote:
    > > >
    > > > > I'm new to the newsgroups, do questions get answered usually here or is there
    > > > > a more active site i should try posting to?
    > > > >
    > > > > Thanks you
    > > > >
    > > > > "Jaybuffet" wrote:
    > > > >
    > > > > > my aspx has something like this
    > > > > >
    > > > > > <asp:Repeater id="Repeater1" runat="server">
    > > > > > <ItemTemplate>
    > > > > > <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>'
    > > > > > showItem="true"/>
    > > > > > </ItemTemplate>
    > > > > > /asp:Repeater>
    > > > > >
    > > > > > The DataSource for this Repeater is a CollectionBase of objects and is
    > > > > > assigned and bound on Page_Load.
    > > > > >
    > > > > > Now I have a Calendar control that fires a SelectionChanged. I want that to
    > > > > > crate a new Collection of objects based on the selected date and rebound.
    > > > > > However it doesn't seem to keep the Container.DataItem. The control shows a
    > > > > > null object however the static fields are passed (i.e. the showPass shows
    > > > > > "true" when debugging).
    > > > > >
    > > > > > What am I doing wrong? Any help would be much appreciated.
    > > > > >
     
    =?Utf-8?B?SmF5YnVmZmV0?=, Feb 18, 2006
    #7
  8. RE: Custom control within repeater with custom object binding

    That might be the problem. It seems on initial load in sets the obj property
    and all other properties before Page_Load on the control. But after i change
    the month it then does the user controls Page_Load first, then sets the
    properties. What am i missing?

    "Phillip Williams" wrote:

    > If I create a demo that matches the description that you posted I do not get
    > the problem that you got. Here is the demo:
    > http://www.webswapp.com/demos/feb162006.aspx
    >
    > The problem you got could have happened if you had added your custom control
    > to the page programmatically (instead of declaratively as you posted below).
    >
    > --
    > HTH,
    > Phillip Williams
    > http://www.societopia.net
    > http://www.webswapp.com
    >
    >
    > "Jaybuffet" wrote:
    >
    > > Not sure if this is correct but this is how i ended up fixing it... don't
    > > know if its a kludge, but it seems to work.. On initial page load it sets
    > > the obj property twice however, but oh well.
    > >
    > > in repeater_itemcreated i put if((e.Item.Controls.Count>1) &&
    > > (e.Item.Controls[1].GetType().Name=="mycontrol.ascx"))
    > > ((mycontrol)e.Item.Controls[1]).obj = (obj)e.Item.DataItem;
    > >
    > > To answer your questions so maybe i can get a better solution:
    > >
    > > Calendar is elsewhere on the page, not in a repeater. There was a typo, i
    > > didn't mean "showPass", i meant "showItem", as the code snippet has and yes
    > > it is a property on my ascx.
    > >
    > > When i debug the property that sets the "obj" and I step through, the
    > > initial page load works great. I set the repeater datasource to a collection
    > > of objects then bind. When a breakpoint is set on the set method in the
    > > "obj" property it is triggered on initial page_load, however, after i select
    > > a date and then in calendar_selectionchanged i select a different datasource
    > > (filtered based on the day) and then bind, it never reaches that breakpoint.
    > >
    > > Don't know if i am explaing this correctly, but i am trying.
    > >
    > > Thank you for your help!!
    > >
    > > "Phillip Williams" wrote:
    > >
    > > > Questions get answered fairly quickly here. Your question however has a few
    > > > ambiguities:
    > > >
    > > > 1- when you say "However it doesn't seem to keep the Container.DataItem" you
    > > > did not clarify what are you referring to. If you are referring to the
    > > > Calender that is within the RepeaterItem then what method are you using and
    > > > in which event are you attempting to get the DataItem?
    > > >
    > > > 2- when you say "The control shows a null object however the static fields
    > > > are passed (i.e. the showPass shows "true" when debugging)." Which control
    > > > are you referring to that has a null value? What are “static fields"? And
    > > > what is "showPass"? Is "showPass" a customized property of your control?
    > > >
    > > > --
    > > > HTH,
    > > > Phillip Williams
    > > > http://www.societopia.net
    > > > http://www.webswapp.com
    > > >
    > > >
    > > > "Jaybuffet" wrote:
    > > >
    > > > > I'm new to the newsgroups, do questions get answered usually here or is there
    > > > > a more active site i should try posting to?
    > > > >
    > > > > Thanks you
    > > > >
    > > > > "Jaybuffet" wrote:
    > > > >
    > > > > > my aspx has something like this
    > > > > >
    > > > > > <asp:Repeater id="Repeater1" runat="server">
    > > > > > <ItemTemplate>
    > > > > > <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>'
    > > > > > showItem="true"/>
    > > > > > </ItemTemplate>
    > > > > > /asp:Repeater>
    > > > > >
    > > > > > The DataSource for this Repeater is a CollectionBase of objects and is
    > > > > > assigned and bound on Page_Load.
    > > > > >
    > > > > > Now I have a Calendar control that fires a SelectionChanged. I want that to
    > > > > > crate a new Collection of objects based on the selected date and rebound.
    > > > > > However it doesn't seem to keep the Container.DataItem. The control shows a
    > > > > > null object however the static fields are passed (i.e. the showPass shows
    > > > > > "true" when debugging).
    > > > > >
    > > > > > What am I doing wrong? Any help would be much appreciated.
    > > > > >
     
    =?Utf-8?B?SmF5YnVmZmV0?=, Feb 18, 2006
    #8
  9. RE: Custom control within repeater with custom object binding

    Any ideas on how to make this work with the setting of control properties in
    the Page_Load. Try adding another property to the control that is a bool and
    then setting visibility on part of the control based on that property with
    the object binding still. Does it make a difference if I am doing this in C#
    with codebehind. I tried modifiying your example to

    <script language="VB" runat="server">
    Private _obj as ArrayList

    Public Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs)
    label1.Text = _obj.Item(0)
    Label2.Text = _obj.Item(1)
    Label3.Text = _obj.Item(2)

    End Sub

    Public WriteOnly Property obj() As ArrayList
    Set(ByVal Value As ArrayList)
    _obj = Value

    End Set
    End Property
    </script>

    but it never does the Page_Load, but in my project it does.

    Thanks for your help.

    "Phillip Williams" wrote:

    > If I create a demo that matches the description that you posted I do not get
    > the problem that you got. Here is the demo:
    > http://www.webswapp.com/demos/feb162006.aspx
    >
    > The problem you got could have happened if you had added your custom control
    > to the page programmatically (instead of declaratively as you posted below).
    >
    > --
    > HTH,
    > Phillip Williams
    > http://www.societopia.net
    > http://www.webswapp.com
    >
    >
    > "Jaybuffet" wrote:
    >
    > > Not sure if this is correct but this is how i ended up fixing it... don't
    > > know if its a kludge, but it seems to work.. On initial page load it sets
    > > the obj property twice however, but oh well.
    > >
    > > in repeater_itemcreated i put if((e.Item.Controls.Count>1) &&
    > > (e.Item.Controls[1].GetType().Name=="mycontrol.ascx"))
    > > ((mycontrol)e.Item.Controls[1]).obj = (obj)e.Item.DataItem;
    > >
    > > To answer your questions so maybe i can get a better solution:
    > >
    > > Calendar is elsewhere on the page, not in a repeater. There was a typo, i
    > > didn't mean "showPass", i meant "showItem", as the code snippet has and yes
    > > it is a property on my ascx.
    > >
    > > When i debug the property that sets the "obj" and I step through, the
    > > initial page load works great. I set the repeater datasource to a collection
    > > of objects then bind. When a breakpoint is set on the set method in the
    > > "obj" property it is triggered on initial page_load, however, after i select
    > > a date and then in calendar_selectionchanged i select a different datasource
    > > (filtered based on the day) and then bind, it never reaches that breakpoint.
    > >
    > > Don't know if i am explaing this correctly, but i am trying.
    > >
    > > Thank you for your help!!
    > >
    > > "Phillip Williams" wrote:
    > >
    > > > Questions get answered fairly quickly here. Your question however has a few
    > > > ambiguities:
    > > >
    > > > 1- when you say "However it doesn't seem to keep the Container.DataItem" you
    > > > did not clarify what are you referring to. If you are referring to the
    > > > Calender that is within the RepeaterItem then what method are you using and
    > > > in which event are you attempting to get the DataItem?
    > > >
    > > > 2- when you say "The control shows a null object however the static fields
    > > > are passed (i.e. the showPass shows "true" when debugging)." Which control
    > > > are you referring to that has a null value? What are “static fields"? And
    > > > what is "showPass"? Is "showPass" a customized property of your control?
    > > >
    > > > --
    > > > HTH,
    > > > Phillip Williams
    > > > http://www.societopia.net
    > > > http://www.webswapp.com
    > > >
    > > >
    > > > "Jaybuffet" wrote:
    > > >
    > > > > I'm new to the newsgroups, do questions get answered usually here or is there
    > > > > a more active site i should try posting to?
    > > > >
    > > > > Thanks you
    > > > >
    > > > > "Jaybuffet" wrote:
    > > > >
    > > > > > my aspx has something like this
    > > > > >
    > > > > > <asp:Repeater id="Repeater1" runat="server">
    > > > > > <ItemTemplate>
    > > > > > <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>'
    > > > > > showItem="true"/>
    > > > > > </ItemTemplate>
    > > > > > /asp:Repeater>
    > > > > >
    > > > > > The DataSource for this Repeater is a CollectionBase of objects and is
    > > > > > assigned and bound on Page_Load.
    > > > > >
    > > > > > Now I have a Calendar control that fires a SelectionChanged. I want that to
    > > > > > crate a new Collection of objects based on the selected date and rebound.
    > > > > > However it doesn't seem to keep the Container.DataItem. The control shows a
    > > > > > null object however the static fields are passed (i.e. the showPass shows
    > > > > > "true" when debugging).
    > > > > >
    > > > > > What am I doing wrong? Any help would be much appreciated.
    > > > > >
     
    =?Utf-8?B?SmF5YnVmZmV0?=, Feb 20, 2006
    #9
  10. Re: Custom control within repeater with custom object binding

    Ok, now I understand the problem that you have. Let me continue to use the
    sample that I put on my website to explain the issue that you described.

    1- The page_load event did not fire when you added it to my sample because
    the control tag of my sample had the AutoEventWireUp = "false". To have
    your modification that you added to the page_load working turn the
    AutoEventWireUp to true.

    2- Control load event fires after the web page Load event. This means that
    when you request the page first time, the Page_load (of the main page) is
    triggered, the data is composed and the Control is databound to the
    arraylist. Then the Control's load event fires up and the repeater is
    populated.

    3- Upon postback, the Page_load event is fired but because I have a
    condition If Not Page.IsPostBack Then do not load the data, the Control's
    Load event is fired but there is no data. Then the
    Calender.SelectionChanged event is fired, it populates the data but it does
    not databind because you moved the databinding to the Page_Load which
    happened earlier that than the data became available.

    In other words, you got to pay attention to the sequence of events. Instead
    of databinding upon page load, databind upon setting the obj value of the
    child control.

    ---
    HTH,
    Phillip Williams
    http://www.societopia.net
    http://www.webswapp.com

    "Jaybuffet" <> wrote:
    > Any ideas on how to make this work with the setting of control properties

    in
    > the Page_Load. Try adding another property to the control that is a bool

    and
    > then setting visibility on part of the control based on that property with
    > the object binding still. Does it make a difference if I am doing this in

    C#
    > with codebehind. I tried modifiying your example to
    >
    > <script language="VB" runat="server">
    > Private _obj as ArrayList
    >
    > Public Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArgs)
    > label1.Text = _obj.Item(0)
    > Label2.Text = _obj.Item(1)
    > Label3.Text = _obj.Item(2)
    >
    > End Sub
    >
    > Public WriteOnly Property obj() As ArrayList
    > Set(ByVal Value As ArrayList)
    > _obj = Value
    >
    > End Set
    > End Property
    > </script>
    >
    > but it never does the Page_Load, but in my project it does.
    >
    > Thanks for your help.
    >
    > "Phillip Williams" wrote:
    >
    > > If I create a demo that matches the description that you posted I do not

    get
    > > the problem that you got. Here is the demo:
    > > http://www.webswapp.com/demos/feb162006.aspx
    > >
    > > The problem you got could have happened if you had added your custom

    control
    > > to the page programmatically (instead of declaratively as you posted

    below).
    > >
    > > --
    > > HTH,
    > > Phillip Williams
    > > http://www.societopia.net
    > > http://www.webswapp.com
    > >
    > >
    > > "Jaybuffet" wrote:
    > >
    > > > Not sure if this is correct but this is how i ended up fixing it...

    don't
    > > > know if its a kludge, but it seems to work.. On initial page load it

    sets
    > > > the obj property twice however, but oh well.
    > > >
    > > > in repeater_itemcreated i put if((e.Item.Controls.Count>1) &&
    > > > (e.Item.Controls[1].GetType().Name=="mycontrol.ascx"))
    > > > ((mycontrol)e.Item.Controls[1]).obj = (obj)e.Item.DataItem;
    > > >
    > > > To answer your questions so maybe i can get a better solution:
    > > >
    > > > Calendar is elsewhere on the page, not in a repeater. There was a

    typo, i
    > > > didn't mean "showPass", i meant "showItem", as the code snippet has

    and yes
    > > > it is a property on my ascx.
    > > >
    > > > When i debug the property that sets the "obj" and I step through, the
    > > > initial page load works great. I set the repeater datasource to a

    collection
    > > > of objects then bind. When a breakpoint is set on the set method in

    the
    > > > "obj" property it is triggered on initial page_load, however, after i

    select
    > > > a date and then in calendar_selectionchanged i select a different

    datasource
    > > > (filtered based on the day) and then bind, it never reaches that

    breakpoint.
    > > >
    > > > Don't know if i am explaing this correctly, but i am trying.
    > > >
    > > > Thank you for your help!!
    > > >
    > > > "Phillip Williams" wrote:
    > > >
    > > > > Questions get answered fairly quickly here. Your question however

    has a few
    > > > > ambiguities:
    > > > >
    > > > > 1- when you say "However it doesn't seem to keep the

    Container.DataItem" you
    > > > > did not clarify what are you referring to. If you are referring to

    the
    > > > > Calender that is within the RepeaterItem then what method are you

    using and
    > > > > in which event are you attempting to get the DataItem?
    > > > >
    > > > > 2- when you say "The control shows a null object however the static

    fields
    > > > > are passed (i.e. the showPass shows "true" when debugging)." Which

    control
    > > > > are you referring to that has a null value? What are "static

    fields"? And
    > > > > what is "showPass"? Is "showPass" a customized property of your

    control?
    > > > >
    > > > > --
    > > > > HTH,
    > > > > Phillip Williams
    > > > > http://www.societopia.net
    > > > > http://www.webswapp.com
    > > > >
    > > > >
    > > > > "Jaybuffet" wrote:
    > > > >
    > > > > > I'm new to the newsgroups, do questions get answered usually here

    or is there
    > > > > > a more active site i should try posting to?
    > > > > >
    > > > > > Thanks you
    > > > > >
    > > > > > "Jaybuffet" wrote:
    > > > > >
    > > > > > > my aspx has something like this
    > > > > > >
    > > > > > > <asp:Repeater id="Repeater1" runat="server">
    > > > > > > <ItemTemplate>
    > > > > > > <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>'
    > > > > > > showItem="true"/>
    > > > > > > </ItemTemplate>
    > > > > > > /asp:Repeater>
    > > > > > >
    > > > > > > The DataSource for this Repeater is a CollectionBase of objects

    and is
    > > > > > > assigned and bound on Page_Load.
    > > > > > >
    > > > > > > Now I have a Calendar control that fires a SelectionChanged. I

    want that to
    > > > > > > crate a new Collection of objects based on the selected date and

    rebound.
    > > > > > > However it doesn't seem to keep the Container.DataItem. The

    control shows a
    > > > > > > null object however the static fields are passed (i.e. the

    showPass shows
    > > > > > > "true" when debugging).
    > > > > > >
    > > > > > > What am I doing wrong? Any help would be much appreciated.
    > > > > > >
     
    Phillip Williams, Feb 21, 2006
    #10
    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. MeiMei
    Replies:
    0
    Views:
    585
    MeiMei
    Jan 20, 2004
  2. Weston Weems
    Replies:
    1
    Views:
    664
    Weston Weems
    Sep 30, 2004
  3. mark4asp
    Replies:
    1
    Views:
    590
    mark4asp
    Dec 3, 2007
  4. Matt Sokol
    Replies:
    2
    Views:
    398
    Theo Tillotson
    Aug 7, 2003
  5. Brian Miller
    Replies:
    6
    Views:
    711
    Brian Miller
    Nov 18, 2004
Loading...

Share This Page