TypeName property of ObjectDataSource could not be found

Discussion in 'Getting started' started by rdunn, Oct 24, 2013.

  1. Hi! I just uploaded my first website to discountasp.net. I need it working asap. When I ran it local, it ran fine. When I published my site and set up my MS Sql Server, I am getting this error: TypeName property of ObjectDataSource 'odsState' could not be found.

    This is part of a page where the user enters their address. It is erroring out on loading the dropdown list for the State. Here is my page code:

    Code:
            <asp:TableRow runat="server">
                <asp:tablecell>&nbsp</asp:tablecell><asp:tablecell>&nbsp</asp:tablecell><asp:tablecell>&nbsp</asp:tablecell>
                <asp:tablecell HorizontalAlign="Right">
                    <asp:Label ID="lbl_State" runat="server" Text="State:"></asp:Label>
                </asp:tablecell>
                <asp:tablecell>&nbsp</asp:tablecell><asp:tablecell>&nbsp</asp:tablecell>
                <asp:tablecell>&nbsp</asp:tablecell><asp:tablecell>&nbsp</asp:tablecell>
                <asp:TableCell>
                        <asp:DropDownList ID="ddl_State" runat="server" DataSourceid="odsState" DataTextField="StateAbbrev" DataValueField="Id" AppendDataBoundItems="true"></asp:DropDownList>
                        <asp:ObjectDataSource ID="odsState" runat="server" SelectMethod="fGetState" TypeName="clSearch"></asp:ObjectDataSource>
                        <asp:RequiredFieldValidator ID="rfvState" runat="server" InitialValue="0" ErrorMessage="*Required Field" ControlToValidate="ddl_State" ForeColor="Red" Display="Static"></asp:RequiredFieldValidator>
                </asp:TableCell>
            </asp:TableRow>
    
    Here is my code behind:
    Code:
        Public Function fGetState() As DataTable
            Dim dt As New DataTable()
            Dim com As SqlCommand = Nothing
            Dim con As New SqlConnection("myconnectionstringfromdiscountasp.net;")
     
            con.Open()
            com = New SqlCommand("select id, stateabbrev from state order by id", con)
     
            Dim da As New SqlDataAdapter(com)
     
            Try
                da.Fill(dt)
                dt.TableName = "State"
     
            Catch ex As Exception
     
            End Try
     
            com.Dispose()
            con.Close()
     
            Return dt
     
        End Function
    
    I submitted a support ticket and they referred me to the forum. I looked at several similar posts and have tried changing TypeName="", but that didnt work either. I tried to add a namespace and then put TypeName=namespace.clsearch, but that didnt work either.

    I really don't understand why it worked on local, but not when I published. The only change I made was the connection string from my local instance to the connection string provided by discountasp.net. I did confirm all connection strings are changed.

    I need to get this working today. Thank you for any help you can give.

    Rhonda
     
  2. martino

    martino DiscountASP.NET Staff

    mjp likes this.
  3. Yes, I saw the post. However, this is my first time publishing a web site and I am not familiar with the assembly configuration. Where are the assemblies located? How do you get the public token? Sorry to sound lost, but on this I am. I usually just make changes to existing projects. This is my first one from scratch.
     
  4. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    Recompile your application if you changed the connection string and then re-upload it. It sounds like one of your custom assemblies (.dll files) may not have been updated. Did you also create a web application or web site in Visual Studio?
     
    mjp likes this.
  5. I did a build and then published it out to the host. I have done this several times. How can I know what didn't transfer?
     
  6. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    Please see this link. The TypeName doesn't look right unless you wrote a class called "clsSearch". If you did make this class, make sure it's set to "Compile" and not "Content".
     
  7. Hi Ray. I do have a class called clSearch. Found it is set to Compile.
     
  8. The Copy to Output Direct is set to Do Not Copy. Is this right?
     
  9. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    You can leave it as Do Not Copy. Did you publish your application to a sub-directory by any chance? Because I'm out of ideas.
     
  10. I just thought of something though, I have clSearch in an App_Code folder. It is not in the main folder where the page is. Could that be an issue?
     
  11. It is published to my site/app1.
     
  12. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    No, but if you published your site to /app1, it will probably look in the directory /app1/bin. You need to make sure you mark the directory as a web application so that it can find the correct /bin folder. Or copy the .dll from the /app1/bin to the /bin folder of root of your account.
     
  13. I'm sorry to bother you, but I am lost. Lol. Where do I mark the directory as a web application? If I don't do that, is the .dll you are speaking of in my control panel on the site? Which is better/easier?
     
  14. I am using Visual Studio Web Developer, if that makes a difference.
     
  15. martino

    martino DiscountASP.NET Staff

    You can mark it as a web application starting point using the the tool in the control panel. Its located in the Web Application Tool section.
     
  16. It is showing as a web application. One thing I should have mentioned is the error is when you click the Register tab.
     
  17. I found the issue, with some help. it was with the namespace. Thanks for all your help.
     
    RayH likes this.

Share This Page