asp.net - DotNetNuke: ObjectDataSource for GridView not being found -
as follow-up previous question gridview , dotnetnuke, i'm having little more trouble getting things act correctly. right have simple gridview in ascx file , bind data gridview in .cs file so:
discoverycontroller objdiscoverys = new discoverycontroller(); list<discoveryinfo> lstdiscoveries = objdiscoverys.getdiscoverys(moduleid); grddiscoverys.datasource = lstdiscoveries; grddiscoverys.databind();
this works. however, have seen alternate method in tutorial instead defines <asp:objectdatasource>
in controller, , seems allow designer more intelligent things, such add functioning delete buttons through checkbox. later on in tutorial, see inline editing being done well, functionality desire.
so decided give shot. wit:
<asp:objectdatasource id="objdatasource" runat="server" typename="mycompany.modules.discovery.discoverycontroller" />
as dll file in bin folder named mycompany.modules.discovery (which matches assembly name , default namespace have set in c# project), makes perfect sense. tutorial says, used designer attempt bind data source gridview.
however, error message can't loaded. namespace names , class name match up, , can bind codebehind, gives?
edit: follow up. after experimentation, have discovered while designer cannot see module, .ascx template can. putting in .ascx file seems work...for part:
<asp:objectdatasource id="objdatasource" runat="server" typename="mycompany.modules.discovery.discoverycontroller" selectmethod="getdiscoverys" updatemethod="updatediscovery" deletemethod="deletediscovery"> <selectparameters> <asp:querystringparameter name="moduleid" querystringfield="mid" /> </selectparameters> <updateparameters> <asp:querystringparameter name="moduleid" querystringfield="mid" /> </updateparameters> <deleteparameters> <asp:querystringparameter name="moduleid" querystringfield="mid" /> </deleteparameters> </asp:objectdatasource> <asp:gridview id="grddiscoverys" runat="server" datasourceid="objdatasource" enablemodelvalidation="true" autogeneratecolumns="false" autogenerateeditbutton="true" autogeneratedeletebutton="true" datakeynames="itemid"> <columns> <asp:boundfield datafield="itemid" headertext="#" readonly="true" /> <asp:boundfield datafield="title" headertext="title" /> <asp:boundfield datafield="image" headertext="image url" /> <asp:boundfield datafield="link" headertext="link" /> </columns> </asp:gridview>
fantastic...it looks i've mirrored of functionality of designer have added...except 1 teensy little thing. automatic update doesn't update.
more specifically, message when try update field:
objectdatasource 'objdatasource' not find non-generic method 'updatediscovery' has parameters: moduleid, title, image, link, itemid.
of course doesn't work! method signature goes this:
public void updatediscovery(discoveryinfo objdiscovery)
at point, i'm close getting working can taste it, , dal-be-damned i'm change function takes 5 exact params instead of data object. however, tutorial referenced above seemed somehow convince automatic update pass data object, i'm kind of curious know how got away it.
change object data source declaration match update method:
public void updatediscovery(discoveryinfo objdiscovery)
use single parameter in update parameter declaration:
<updateparameters> <asp:parameter name="objdiscovery" /> </updateparameters>
use object data source's updating event create object existing control set , assign parameter's default value. good luck
Comments
Post a Comment