Problem: OnItemCommand on DataGrid causes error in module

Last post 10-17-2005 6:28 AM by bazz. 3 replies.

Sort Posts:

  • Problem: OnItemCommand on DataGrid causes error in module

    10-16-2005, 6:59 PM

    Hey guys, working on my second DNN module and I'm trying to implement a basic master/detail setup. I have a datagrid on the .ascx page:

    <asp:datagrid id="dgAbstractList" runat="server"  OnItemCommand="lbShowAbstract_Click" AutoGenerateColumns="False">

    Here is the event handler from the codebehind page:

    Protected WithEvents dgAbstractList As System.Web.UI.WebControls.DataGrid

    Private Sub lbShowAbstract_Click( _
               ByVal sender As System.Object, _
               ByVal e As DataGridCommandEventArgs)

            End Sub

    When I remove OnItemCommand="lbShowAbstract_Click" the page loads fine.

    What am I doing wrong?
  • Re: Problem: OnItemCommand on DataGrid causes error in module

    10-16-2005, 10:10 PM
    I fixed the problem by making the event handler public.
  • Re: Problem: OnItemCommand on DataGrid causes error in module

    10-16-2005, 11:46 PM
    • Participant
      1,025 point Participant
    • djbaldwin
    • Member since 09-11-2003, 1:34 PM
    • Ontario, Canada
    • Posts 205

    The only thing I can see is

    Private Sub lbShowAbstract_Click( _
               ByVal sender As System.Object, _
               ByVal e As DataGridCommandEventArgs) Handles dgAbstractList.ItemCommand

    What errors are you getting?

    Dwayne J. Baldwin
  • Re: Problem: OnItemCommand on DataGrid causes error in module

    10-17-2005, 6:28 AM
    • Member
      500 point Member
    • bazz
    • Member since 09-20-2002, 2:56 AM
    • Scotland
    • Posts 100
    You wouldn't have to go as far a declaring it public, protected would give it enough permissions.

    I would recommend djbaldwin behind code which would mean your html would look like:

    <asp:datagrid id="dgAbstractList" runat="server" AutoGenerateColumns="False">

    And since you have declared it "protected withevents" int your behind code, the event should fire.

    hth
Page 1 of 1 (4 items)