Can't databind across Web user controls

A

Axel Dahmen

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top