Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0how to wire a gridview from code behindhow to wire a gridview from code behind
Previous
 
Next
New Post
11/19/2007 8:14 PM
 

HI all, im designing and programming my first dnn module, and i want to have a gridview populated, but not in page load, but at a button press... for that and another reasons i want to wire the grid from code behind, and ill like to know if someone can give me a hand on this.

I already coded the dal and th bl, now i just want to pass on the databjects, heres my approach:

 

 ObjectDataSource Cat = new ObjectDataSource();
            Cat.DataObjectTypeName = YourCompany.Modules.Catalogo.CatalogoInfo;
            Cat.DeleteMethod = "DeleteCatalogo";
            Cat.InsertMethod = "AddCatalogo";
            Cat.SelectMethod = "GetCatalogo";
            Cat.UpdateMethod = "UpdateCatalogo";
            Cat.TypeName = "CatalogoController";
            Cat.SelectParameters.Add("Moduleid", TypeCode.Int32, "00");
            Cat.SelectParameters.Add("Cod_Artic", TypeCode.String, "00");

            GridView1.DataSource = Cat;
            GridView1.DataBind();

 

but i get this error:

 

DotNetNuke.Services.Exceptions.ModuleLoadException: c:\Inetpub\wwwroot\DotNetNuke\DesktopModules\Catalogo\ViewCatalogo.ascx.cs(126): error CS0119: 'YourCompany.Modules.Catalogo.CatalogoInfo' is a 'type', which is not valid in the given context ---> System.Web.HttpCompileException: c:\Inetpub\wwwroot\DotNetNuke\DesktopModules\Catalogo\ViewCatalogo.ascx.cs(126): error CS0119: 'YourCompany.Modules.Catalogo.CatalogoInfo' is a 'type', which is not valid in the given context at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath) at System.Web.UI.TemplateControl.LoadControl(String virtualPath) at DotNetNuke.UI.Skins.Skin.InjectModule(Control objPane, ModuleInfo objModule, PortalSettings PortalSettings) --- End of inner exception stack trace ---

 

Can anyone point me in the right direction? i´ve found a lot of examples wireing the grid on the client side, but none un the codebehind, tanks a lot for your time.

Farewell

 
New Post
11/20/2007 1:50 AM
 

Actually, as long as you don't call DataBind in the Page_Load event and, instead, call it in the event handler for your button's click event, you should be able to configure your GridView in the designer. The Data Source isn't queried until you call DataBind.

If you do still need to use the code behind, the error you are getting is because you are passing the type object YourCompany.Modules.Catalogo.CatalogoInfo to DataObjectTypeName which is expecting a string. You could just wrap the type name in quotes to make it a string, but I recommend using this code instead:

Cat.DataObjectTypeName = typeof(YourCompany.Modules.Catalogo.CatalogoInfo).FullName;

(it looks like you're in C#, but just in case you are using VB.net, just replace "typeof" with "GetType" and drop the semi-colon)


Andrew Nurse
DotNetNuke Core Team Member and Reports Module Project Lead
Microsoft Certified Professional Developer

 
New Post
11/28/2007 2:59 PM
 

Hi Andrew, just noticed that i forgot to thank you for your help. Tnks a millon and pardon for the delay.

 

Farewell

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0how to wire a gridview from code behindhow to wire a gridview from code behind


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out