D
danhickson
Guest
Hello, I am pulling my hair out with this error. I dont know what is causing it and I have tried everything I can think of.
I am trying to populate the grid using the select method.
Grid:
<asp:GridView ID="GridView1" ItemType="PrincePortalWeb.Models.supplier" SelectMethod="GridView1_GetData" runat="server"></asp:GridView>
My select method:
public IQueryable<supplier> SuppliersGrid_GetData([Control("searchText")] string search)
{
SupplierDBModel db = new SupplierDBModel();
var query = from s in db.suppliers
where s.suppliername.ToUpper() == "SUPPLIER"
select s;
return query;
}
My supplier context:
public partial class SupplierDBModel : DbContext
{
public SupplierDBModel()
: base("name=SupplierDBModel")
{
// Database.SetInitializer(new MigrateDatabaseToLatestVersion<SupplierDBModel, EF6Console.Migrations.Configuration>());
}
public virtual DbSet<supplier> suppliers { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
}
}
supplier model:
public
partial class supplier
{
public int supplierid { get; set; }
[Required]
[StringLength(50)]
public string suppliername { get; set; }
[StringLength(50)]
public string address1 { get; set; }
[StringLength(50)]
public string county { get; set; }
[StringLength(50)]
public string country { get; set; }
[StringLength(50)]
public string telephone { get; set; }
[StringLength(50)]
public string address2 { get; set; }
[StringLength(11)]
public string postcode { get; set; }
[StringLength(20)]
public string webstatus { get; set; }
[StringLength(50)]
public string status { get; set; }
[StringLength(50)]
public string LastreviewedBy { get; set; }
[Column(TypeName = "datetime2")]
public DateTime Whencompliant { get; set; }
[Column(TypeName = "datetime2")]
public DateTime Reviewdate { get; set; }
}
error :
The Select Method must return one of "IQueryable<PrincePortalWeb.Models.Supplier>" or "IEnumerable<PrincePortalWeb.Models.Supplier>" or "PrincePortalWeb.Models.Supplier" when ItemType is set to "PrincePortalWeb.Models.Supplier".
What am i doing wrong?
thanks
Continue reading...
I am trying to populate the grid using the select method.
Grid:
<asp:GridView ID="GridView1" ItemType="PrincePortalWeb.Models.supplier" SelectMethod="GridView1_GetData" runat="server"></asp:GridView>
My select method:
public IQueryable<supplier> SuppliersGrid_GetData([Control("searchText")] string search)
{
SupplierDBModel db = new SupplierDBModel();
var query = from s in db.suppliers
where s.suppliername.ToUpper() == "SUPPLIER"
select s;
return query;
}
My supplier context:
public partial class SupplierDBModel : DbContext
{
public SupplierDBModel()
: base("name=SupplierDBModel")
{
// Database.SetInitializer(new MigrateDatabaseToLatestVersion<SupplierDBModel, EF6Console.Migrations.Configuration>());
}
public virtual DbSet<supplier> suppliers { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
}
}
supplier model:
public
partial class supplier
{
public int supplierid { get; set; }
[Required]
[StringLength(50)]
public string suppliername { get; set; }
[StringLength(50)]
public string address1 { get; set; }
[StringLength(50)]
public string county { get; set; }
[StringLength(50)]
public string country { get; set; }
[StringLength(50)]
public string telephone { get; set; }
[StringLength(50)]
public string address2 { get; set; }
[StringLength(11)]
public string postcode { get; set; }
[StringLength(20)]
public string webstatus { get; set; }
[StringLength(50)]
public string status { get; set; }
[StringLength(50)]
public string LastreviewedBy { get; set; }
[Column(TypeName = "datetime2")]
public DateTime Whencompliant { get; set; }
[Column(TypeName = "datetime2")]
public DateTime Reviewdate { get; set; }
}
error :
The Select Method must return one of "IQueryable<PrincePortalWeb.Models.Supplier>" or "IEnumerable<PrincePortalWeb.Models.Supplier>" or "PrincePortalWeb.Models.Supplier" when ItemType is set to "PrincePortalWeb.Models.Supplier".
What am i doing wrong?
thanks
Continue reading...