c# - Trying to filter data in grid, receiving "Cannot create an instance of the static class" error -


i attempting filter items populated in grid in code behind. when try call adapter data access layer, receiving following error:

cannot create instance of static class 'sftip.dataaccesslayer.inventoryadapter'

the filter meant display items in grid related user role (assetownershipprogramids).

the error in segment new inventoryadapter() of line:

filteredlist = new inventoryadapter().getallbyfilter(inventoryfilter); 

here code filter trying build:

public list<inventory> bindgrid() {     list<inventory> filteredlist = new list<inventory>();     searchfilterinventory inventoryfilter = new searchfilterinventory();     user currentuser;      currentuser = (session["currentuser"] == null) ? (user)session["currentuser"] : new user();     if (currentuser.adminprograms.count > 0)     {         inventoryfilter.assetownershipprogramids.add(currentuser.adminprograms[0].referenceid);         filteredlist = new inventoryadapter().getallbyfilter(inventoryfilter);     }      return filteredlist; } 

can provide guidance on going wrong? know simple - inherited project , i'm still trying connect dots. thank taking look.

the error says all.

you cannot create instance of static class. if wanted make that, remove static keyword class declaration.

msdn says:

a static class same non-static class, there 1 difference: static class cannot instantiated. in other words, cannot use new keyword create variable of class type. because there no instance variable, access members of static class using class name itself.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -