Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 12th, 2012  |  syntax: None  |  size: 3.52 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ObjectDataSource 's' could not find a non-generic method GetAllUsers
  2. public static DataTable GetAllobjs(SPWeb objWeb)
  3. {
  4.     DataTable tmpData = new DataTable();
  5.     try
  6.     {
  7.         allProjects.Columns.Add(ColumnNames.1);
  8.         allProjects.Columns.Add(ColumnNames.2);
  9.         allProjects.Columns.Add(ColumnNames.3);
  10.         allProjects.Columns.Add(ColumnNames.4);
  11.         allProjects.Columns.Add(ColumnNames.5);
  12.         allProjects.Columns.Add(ColumnNames.6);
  13.         allProjects.Columns.Add(ColumnNames.7);
  14.         allProjects.Columns.Add(ColumnNames.8);
  15.         allProjects.Columns.Add(ColumnNames.9);
  16.  
  17.         //Get the raw project data
  18.         List<obj> data= DataAquisition.GetAllobj(objWeb);
  19.  
  20.         /// Loop through the raw data.
  21.         foreach (obj currentInformation in data)
  22.         {
  23.             // Creates a new data row containing information required and adds it to the DATAtable
  24.         }
  25.     }
  26.     catch (Exception exc)
  27.     {
  28.         // Logs errors here
  29.     }
  30.     return tmpData;
  31. }
  32.        
  33. [DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
  34. public DataTable GetAllUsers()
  35. {
  36.     return Data.GetAllobjs(SPContext.Current.Web);
  37. }
  38.        
  39. ObjectDataSource d = new ObjectDataSource();
  40. d.ID = "s";
  41. d.SelectMethod = "GetAllUsers";
  42. d.TypeName = SPGridView.GetType().AssemblyQualifiedName;
  43. this.Controls.Add(d);
  44. /// Apply a data source to the SPGrid View
  45. SPGridView.DataSourceID = d.ID;
  46.        
  47. d.TypeName = SPGridView.GetType().AssemblyQualifiedName;
  48.        
  49. d.TypeName = this.GetType().AssemblyQualifiedName;
  50.        
  51. using System;
  52. using System.Data;
  53. using System.Configuration;
  54. using System.Collections;
  55. using System.Web;
  56. using System.Web.Security;
  57. using System.Web.UI;
  58. using System.Web.UI.WebControls;
  59. using System.Web.UI.WebControls.WebParts;
  60. using System.Web.UI.HtmlControls;
  61.  
  62. namespace Q11454649WebApp
  63. {
  64.     public partial class _Default : System.Web.UI.Page
  65.     {
  66.         protected void Page_Load(object sender, EventArgs e)
  67.         {
  68.             if (!this.IsPostBack)
  69.             {
  70.                 ObjectDataSource d = new ObjectDataSource();
  71.                 d.ID = "s";
  72.                 d.SelectMethod = "GetAllUsers";
  73.                 //d.TypeName = SPGridView.GetType().AssemblyQualifiedName;
  74.                 d.TypeName = this.GetType().AssemblyQualifiedName;
  75.                 this.Controls.Add(d);
  76.                 /// Apply a data source to the SPGrid View
  77.                 SPGridView.DataSourceID = d.ID;
  78.             }
  79.         }
  80.  
  81.         [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
  82.         public string[] GetAllUsers()
  83.         {
  84.             return new string[] { "Joe", "Alan", "Michel" };
  85.         }
  86.     }                              
  87. }
  88.        
  89. <%@ Page Language="C#" AutoEventWireup="true" Codebehind="Default.aspx.cs" Inherits="Q11454649WebApp._Default" %>
  90.  
  91. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  92. <html xmlns="http://www.w3.org/1999/xhtml">
  93. <head runat="server">
  94.     <title>Untitled Page</title>
  95. </head>
  96. <body>
  97.     <form id="form1" runat="server">
  98.         <div>
  99.             <asp:GridView ID="SPGridView" runat="server" AutoGenerateColumns="False">
  100.                 <Columns>
  101.                     <asp:TemplateField>
  102.                         <ItemTemplate>
  103.                             <asp:Label ID="Label1" runat="server" Text="<%# Container.DataItem %>"></asp:Label>
  104.                         </ItemTemplate>
  105.                     </asp:TemplateField>
  106.                 </Columns>
  107.             </asp:GridView>
  108.         </div>
  109.     </form>
  110. </body>
  111. </html>