Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old February 5th, 2007, 04:05 PM
Authorized User
 
Join Date: Dec 2006
Location: , , .
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need help with SqlDataSource control

Hello:

I forgot what to do in a case like this. I have a SqlDataSource control within a label and I want to allow auto sorting, but when I click on the sort link the page comes back with:

The SqlDataSource control 'sqlViewIncompleteForms' does not have a naming container. Ensure that the control is added to the page before calling DataBind.

[HttpException (0x80004005): The SqlDataSource control 'sqlViewIncompleteForms' does not have a naming container. Ensure that the control is added to the page before calling DataBind.]
   System.Web.UI.WebControls.DataBoundControlHelper.F indControl(Control control, String controlID) +1590679
   System.Web.UI.WebControls.ControlParameter.Evaluat e(HttpContext context, Control control) +76
   System.Web.UI.WebControls.Parameter.UpdateValue(Ht tpContext context, Control control) +46
   System.Web.UI.WebControls.ParameterCollection.Upda teValues(HttpContext context, Control control) +103
   System.Web.UI.WebControls.SqlDataSource.LoadComple teEventHandler(Object sender, EventArgs e) +40
   System.EventHandler.Invoke(Object sender, EventArgs e) +0
   System.Web.UI.Page.OnLoadComplete(EventArgs e) +2010392
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1209

How do I over come this? Do I have to use the find control method on page_load? Here is the code portion .vb

<% 'Label which contains the default.aspx home content %>
<asp:Label ID="recip_home_display" runat="server" Visible="false">
    <div align="center" class="HeaderSmall">Incomplete Recip Submissions</div>
    <asp:GridView ID="RecipStatusGridView" runat="server" AutoGenerateColumns="False" BorderWidth="0px" DataKeyNames="queue_id"
        DataSourceID="sqlViewIncompleteForms" AllowPaging="True" AllowSorting="True" CellPadding="2" CellSpacing="2" CssClass="TextSmall" HorizontalAlign="Center" Width="500px" Visible="False">
        <Columns>
            <asp:BoundField DataField="queue_id" HeaderText="Incomplete Listings" HtmlEncode="False"
                InsertVisible="False" ReadOnly="True" SortExpression="queue_id">
                <ControlStyle CssClass="LinkNormal" />
                <ItemStyle HorizontalAlign="Center" />
                <HeaderStyle HorizontalAlign="Center" />
            </asp:BoundField>
            <asp:BoundField DataField="form_type" HeaderText="Listing Type" SortExpression="form_type">
                <ItemStyle HorizontalAlign="Center" />
                <HeaderStyle HorizontalAlign="Center" />
            </asp:BoundField>
            <asp:BoundField DataField="listing_address" HeaderText="Listing Address" ReadOnly="True"
                SortExpression="listing_address">
                <ItemStyle HorizontalAlign="Center" />
                <HeaderStyle HorizontalAlign="Center" />
            </asp:BoundField>
            <asp:BoundField DataField="last_modified_date" DataFormatString="{0:d}" HeaderText="Last Modified"
                HtmlEncode="False" SortExpression="last_modified_date">
                <ItemStyle HorizontalAlign="Center" />
                <HeaderStyle HorizontalAlign="Center" />
            </asp:BoundField>
        </Columns>
        <HeaderStyle BackColor="#5C6F8D" />
        <AlternatingRowStyle BackColor="#e9eaf0" />
    </asp:GridView>
    <asp:SqlDataSource ID="sqlViewIncompleteForms" runat="server" ProviderName="System.Data.SqlClient" ConnectionString="<%$ Appsettings:connectionstring %>" SelectCommandType="StoredProcedure" SelectCommand="spGetIncompleteForms">
    <SelectParameters>
        <asp:ControlParameter ControlID="active_member_id" Name="AgentId" />
    </SelectParameters>
</asp:SqlDataSource>
</asp:Label>

  #2 (permalink)  
Old February 5th, 2007, 05:32 PM
Authorized User
 
Join Date: Dec 2006
Location: , , .
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, someone helped me on this issue. It is better to use a placeholder control instead to avoid the child controls.



Similar Threads
Thread Thread Starter Forum Replies Last Post
SqlDataSource ControlParameter Cannot Find Control AspNetGuy ASP.NET 3.5 Basics 1 June 25th, 2008 07:44 AM
Binding SQLDataSource To A Label Control sg225551 ASP.NET 2.0 Basics 1 January 16th, 2008 10:36 AM
SqlDataSource control error binici ASP.NET 2.0 Basics 1 January 19th, 2007 08:02 PM
SqlDatasource filter using formview control tony_j_hug ASP.NET 2.0 Basics 2 October 17th, 2005 05:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.