locked
TypeName property of ObjectDataSource 'ObjectDataSource1' could not be found RRS feed

  • Question

  • User1899914733 posted

    Hello,

    i'm building a website and are using an Objectdatasource to populate my gridview.
    When bulding the website i keep getting error: The type specified in the TypeName property of ObjectDataSource 'ObjectDataSource1' could not be found

    I've read on the net that you have to specify the complete assembly namespace. But how do you get the assemblyname and complete namespace naming??

    I've tried different names for the typename. The code I have is below, look at: TypeName="System.Web.UI.Page.Account_Rubriceren.UserDAO

     

    <%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Rubriceren.aspx.cs" Inherits="Account_Rubriceren" %>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    
    <h3>Rubriceren</h3>
    <h4>Invoerlijst rubriceren</h4>
    
    
    <asp:ObjectDataSource ID="ObjectDataSource1" EnablePaging="true"  
    
            runat="server" SelectCountMethod="GetUserCount"
    
            SelectMethod="BindUsers" TypeName="System.Web.UI.Page.Account_Rubriceren.UserDAO" 
    
            StartRowIndexParameterName="startRowIndex" 
            MaximumRowsParameterName="maximumRows">
    
             </asp:ObjectDataSource>
    
    
    <asp:GridView ID="gvUsers" runat="server" AllowPaging="True" DataSourceID="ObjectDataSource1" PageSize="2">
    
            </asp:GridView>
    public partial class Account_Rubriceren : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
               
        }
    
        public class UserDAO
        {
    
            public DataTable BindUsers(int startRowIndex, int maximumRows)
            {
    
                SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionWebBankbeheer"].ConnectionString);
    
                SqlCommand com = new SqlCommand("[Selecteer_transacties]", con);
    
                com.CommandType = CommandType.StoredProcedure;
    
                com.Parameters.Add("@RowIndex", SqlDbType.Int, 4).Value = startRowIndex;
    
                com.Parameters.Add("@MaxRows", SqlDbType.Int, 4).Value = maximumRows;
    
                SqlDataAdapter ada = new SqlDataAdapter(com);
    
                DataTable dt = new DataTable();
    
                ada.Fill(dt);
    
                return dt;
    
            }
    
            public int GetUserCount()
            {
    
                SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionWebBankbeheer"].ConnectionString);
    
                con.Open();
    
                SqlCommand com = new SqlCommand("GetUserCount", con);
    
                SqlDataReader dr = com.ExecuteReader();
    
                int count = 0;
    
                while (dr.Read())
                {
    
                    if (dr["UserCOUNT"] != null)
    
                        int.TryParse(dr["UserCOUNT"].ToString(), out count);
    
                }
    
                return count;
    
            }
            
        }
    
    
    
    
    }


     

    The website page is Rubriceren.aspx. The name of the website is Website1.

    Can somebody help me with this? Thanx in advanced.
     

    Monday, January 3, 2011 12:52 AM

Answers

  • User2004711764 posted

    What is the namespace of your page? And why you embedded your DAO class into a page? It's confusing and hardly to reuse.


    Morzel

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 3, 2011 3:16 AM

All replies

  • User2004711764 posted

    What is the namespace of your page? And why you embedded your DAO class into a page? It's confusing and hardly to reuse.


    Morzel

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 3, 2011 3:16 AM
  • User1899914733 posted

    Hello Morzel,

    You where right. I made the class external and added it in the folder app_code.

    Now it works. Thnx. Cool 

    Monday, January 3, 2011 3:20 PM