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

HomeHomeGetting StartedGetting StartedNew to DNN Plat...New to DNN Plat...OnItemDataBound in Datagrid errorOnItemDataBound in Datagrid error
Previous
 
Next
New Post
6/19/2011 12:01 AM
 
I'm working on a custom module that uses datagrid for which I'm trying to create some totals in the footer.  I'd like to use the OnItemDataBound subroutine to put the totals in the footer.  However, I keep getting an error when I add a OnItemDataBound parameter to my datagrid. I'm obviously doing something wrong but I can't figure out what it is.  My datagrid has the following parameters:
<asp:DataGrid ID="dgB2BViewCart"
            AutoGenerateColumns="false"
            ShowFooter="true"
            OnItemDataBound="dgB2BViewCart_ItemDataBound"
            Width="100%"
            CellPadding="3"
            GridLines="None"
            CssClass="Datagrid_Container"
            runat="server" >

The error I keep getting is:
DotNetNuke.Services.Exceptions.ModuleLoadException: D:\Websites2005\DNNDev\DesktopModules\PilotInterface\View.ascx(1041): error BC30456: 'dgB2BViewCart_ItemDataBound' is not a member of 'ASP.desktopmodules_pilotinterface_view_ascx'. ---> System.Web.HttpCompileException: D:\Websites2005\DNNDev\DesktopModules\PilotInterface\View.ascx(1041): error BC30456: 'dgB2BViewCart_ItemDataBound' is not a member of 'ASP.desktopmodules_pilotinterface_view_ascx'. at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean ensureIsUpToDate) at System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath) at DotNetNuke.UI.ControlUtilities.LoadControl[T](TemplateControl containerControl, String ControlSrc) at DotNetNuke.UI.Modules.ModuleHost.LoadModuleControl() --- End of inner exception stack trace ---

If I take the OnItemDataBound attribute out of the datagrid definition I do not get the error. With it in, the error appears.

Any ideas of where to look for the problem would be greatly appreciated.
 
New Post
6/20/2011 11:46 AM
 
I have figured this one out finally.  The reference in the datagrid on the ascx side of the code is:
OnItemDataBound="dgB2BViewCart_ItemDataBound"

And originally I had the following subroutine in my codebehind:
Private Sub dgB2BViewCart_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgB2BViewCart.ItemDataBound

I compared this with code I had working for the sort and pagination for a couple of datagrids and noticed that they were a little different.  I made the following change to the subroutine on the ascx.vb side of things and the code now works:
Sub dgB2BViewCart_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgB2BViewCart.ItemDataBound

If anyone could explain why this works I would appreciate it. All of the examples that I found on the web code it with the 'Private' and being new to both .Net and to DNN I really don't understand when you should use 'Private Sub' and when you just use 'Sub'.

I  hope that what I discovered will save someone else some time.

 
New Post
6/20/2011 11:09 PM
 
In order to hook up an event handler in your .ascx file markup, the event handler must be given Public or Protected scope in the code behind and not Private scope as the .ascx markup inherits the code behind's class and would not be able to "see" a method marked private in its base class. When you eliminated the Private scope keyword from the class's dgB2BViewCard_ItemDataBound method, the default scope is Public.

I also noticed that you are also hooking up to the same ItemDataBound handler by including the Handles keyword in the declaration of the Sub dgB2BViewCard_ItemDataBound.  Use of both approaches to hooking up the same event handler should be avoided. If you were to remove the attribute OnItemDataBound="dgB2BViewCard_ItemDataBound" from the DataGrid's attribute markup in the .ascx file, the application of Handles dgB2BViewCard.ItemDataBound to the method in the code behind shoud be all you need. In that case, the method scope can in fact be made Private.

Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
6/21/2011 12:17 AM
 
William -
Somehow I knew you would have an explanation that made sense.  Thank you very much.
 
Previous
 
Next
HomeHomeGetting StartedGetting StartedNew to DNN Plat...New to DNN Plat...OnItemDataBound in Datagrid errorOnItemDataBound in Datagrid error


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