Can't databind across Web user controls

Discussion in 'ASP .Net Web Controls' started by Axel Dahmen, Dec 6, 2003.

  1. Axel Dahmen

    Axel Dahmen Guest

    Hi,

    I created an ASP.NET page containing an asp:Repeater control... This control
    contains a Web user control of mine which itself contains an asp:Repeater
    control... That control in turn contains a second Web user control of mine
    which again contains an asp:Repeater control...

    When I run the page, I get an error telling me that get_FieldCount() can't
    be performed on a closed SqlDataReader (this error is raised the page).
    However, I did't close any of them. I'm just using three distinct
    SqlDataReaders on the same connection string (but distinct SqlConnection
    objects) simultaneously. Isn't that possible?

    TIA
    Axel Dahmen

    ====
    The hierarchy looks something like:

    Page.aspx
    |------- WUC1.ascx
    |-------- WUC2.ascx


    All three of them contain code similar to the following:

    using (SqlConnection con=new SqlConnection(conStr))
    {
    SqlCommand cmd;

    cmd=con.CreateCommand();
    cmd.CommandText="...";
    con.Open();
    repeater.DataSource=cmd.ExecuteReader();
    repeater.DataBind();
    }

    All three of them use the <%# DataBinder.Eval()%> syntax to perform
    databinding:

    <asp:Repeater Runat="server" ID="repeater" EnableViewState="False">
    <ItemTemplate>
    <axd:Item Runat="server" MyProp='<%#
    DataBinder.Eval(Container.DataItem,"MyCol")%>'/>
    </ItemTemplate>
    </asp:Repeater>
     
    Axel Dahmen, Dec 6, 2003
    #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. David
    Replies:
    0
    Views:
    408
    David
    May 15, 2004
  2. Phil Winstanley [Microsoft MVP ASP.NET]

    Re: using user controls across web applications

    Phil Winstanley [Microsoft MVP ASP.NET], May 15, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    411
    Phil Winstanley [Microsoft MVP ASP.NET]
    May 15, 2004
  3. Vince
    Replies:
    3
    Views:
    336
    Michael Nemtsev [MVP]
    Mar 27, 2008
  4. Michael
    Replies:
    0
    Views:
    247
    Michael
    Dec 29, 2003
  5. Axel Dahmen

    Can't databind across Web user controls

    Axel Dahmen, Oct 25, 2003, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    108
    Axel Dahmen
    Oct 25, 2003
Loading...

Share This Page