none
'System.Data.DataRowView' does not contain a property with the name 'name'

    Question




  • SQL QUERY: This query runs in visual studio 2008 without a problem and retrieves the correct records.

        SQLstring += "SELECT [User].id, [User].last_name, [User].first_name, [User].email, [User].role_id, Course_Assignment.SO_NUR, Course_Assignment.date_complete, Course_Assignment.id ";
    
        SQLstring += "FROM [User] INNER JOIN ";
    
        SQLstring += "Course_Assignment ON [User].id = Course_Assignment.user_id ";
    
        SQLstring += "WHERE ([User].role_id = '1') AND (Course_Assignment.SO_NUR IS NULL) AND (Course_Assignment.date_complete IS NOT NULL)";
    
    

    When running it in the page it gives the error. Here is the page code:

      String[] dataKeys;
    
      Parameter param;
    
    
    
      //mbelcher - only display name of users that have completed the course. 
    
      string SQLstring = "";
    
        SQLstring += "SELECT [User].id, [User].last_name, [User].first_name, [User].email, [User].role_id, Course_Assignment.SO_NUR, Course_Assignment.date_complete, Course_Assignment.id ";
    
        SQLstring += "FROM [User] INNER JOIN ";
    
        SQLstring += "Course_Assignment ON [User].id = Course_Assignment.user_id ";
    
        SQLstring += "WHERE ([User].role_id = '1') AND (Course_Assignment.SO_NUR IS NULL) AND (Course_Assignment.date_complete IS NOT NULL)";
    
    
    
    
    
      try
    
      {
    
       userDataSource.ConnectionString = ConfigurationManager.ConnectionStrings["sqlConnectionString"].ConnectionString;
    
       userDataSource.DataSourceMode = SqlDataSourceMode.DataSet;
    
       userDataSource.ProviderName = "System.Data.SqlClient";
    
       userDataSource.SelectCommand = SQLstring;
    
    
    
    
    
       dataKeys = new String[1] { "id" };
    
       lstUsers.DataSourceID = userDataSource.ID;



    HERE IS THE COMPLETE ERROR:
    DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'name'. 
    
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
    
    
    
    Exception Details: System.Web.HttpException: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'name'.
    
    
    
    Source Error: 
    
    
    
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 
    
    
    
    Stack Trace: 
    
    
    
    
    
    [HttpException (0x80004005): DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'name'.]
    
     System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) +8665125
    
     System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName, String format) +8
    
     System.Web.UI.WebControls.ListControl.PerformDataBinding(IEnumerable dataSource) +332
    
     System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e) +107
    
     System.Web.UI.WebControls.ListControl.PerformSelect() +34
    
     System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73
    
     System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
    
     System.Web.UI.WebControls.BaseDataBoundControl.OnPreRender(EventArgs e) +22
    
     System.Web.UI.WebControls.ListControl.OnPreRender(EventArgs e) +18
    
     System.Web.UI.WebControls.ListBox.OnPreRender(EventArgs e) +12
    
     System.Web.UI.Control.PreRenderRecursiveInternal() +80
    
     System.Web.UI.Control.PreRenderRecursiveInternal() +171
    
     System.Web.UI.Control.PreRenderRecursiveInternal() +171
    
     System.Web.UI.Control.PreRenderRecursiveInternal() +171
    
     System.Web.UI.Control.PreRenderRecursiveInternal() +171
    
     System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842
    
    
    
     
    
    
    
    

    Monday, October 25, 2010 2:15 PM

Answers

  • Figured it out, was with the list control names.


        SQLstring += "SELECT ([User].last_name + ', ' + [User].first_name + ', ' + [User].email) as name, [User].id, [User].role_id, Course_Assignment.SO_NUR, Course_Assignment.date_complete ";
        SQLstring += "FROM [User] INNER JOIN ";
        SQLstring += "Course_Assignment ON [User].id = Course_Assignment.user_id ";
        SQLstring += "WHERE ([User].role_id = '1') AND (Course_Assignment.SO_NUR IS NULL) AND (Course_Assignment.date_complete IS NOT NULL) ";
        SQLstring += "order by name";

     

             <asp:SqlDataSource ID="userDataSource" Runat="server" ></asp:SqlDataSource>
             &nbsp;
             <asp:ListBox ID="lstUsers" runat="server" 
                DataSourceID="userDataSource" 
                DataTextField="name"
                DataValueField="id" 
                SelectionMode="Multiple" 
                Width="399px" Height="337px">
             </asp:ListBox>

    Posted this in case anyone else has an issue.

    • Marked as answer by belcherman Monday, October 25, 2010 2:41 PM
    Monday, October 25, 2010 2:41 PM