Handling events in container controls?

Discussion in 'ASP .Net' started by Barry, Aug 6, 2003.

  1. Barry

    Barry Guest

    Hi,
    I have a sub in a user control that looks like this:

    Public Sub BatchDetail_ItemCommand(ByVal Sender As Object, ByVal e
    As DataListCommandEventArgs)

    Dim cmd As String = CType(e.CommandSource,
    LinkButton).CommandName
    Dim senderlist As DataList = CType(Sender, DataList)

    Select Case cmd
    Case "aestheticBatch"
    senderlist.SelectedItemTemplate =
    Page.LoadTemplate("./Components/AestheticDetailTemplate.ascx")
    Case "adhesiveBatch"
    senderlist.SelectedItemTemplate =
    Page.LoadTemplate("./Components/AdhesiveDetail.ascx")
    Case "aestheticAdhesiveBatch"
    senderlist.SelectedItemTemplate =
    Page.LoadTemplate("./Components/AestheticAdhesive.ascx")
    End Select
    senderlist.SelectedIndex = e.Item.ItemIndex
    senderlist.DataBind()
    End Sub

    It's used to dynamically load a template into the SelectedItemTemplate
    of my DataList. Now, inside the template file
    (AestheticDetailTemplate.ascx), I have another DataList with the
    following definition:

    <asp:datalist id=AestheticDetail datasource='<%#
    GetAestheticDetail(DataBinder.Eval(CType(Container,DataListItem).DataIte
    m, "AestheticBatch")) %>' OnItemCommand="BatchDetail_ItemCommand"
    runat="server" >

    This DataList also contains the following control:
    <asp:Linkbutton ID="Label6" Runat="server" text='<%#
    DataBinder.Eval container.DataItem, "AestheticAdhesiveBatch")
    %>'commandname = "aestheticadhesivebatch"/>

    I want the OnItemCommand from this DataList to call the sub in its
    container (BatchDetail_ItemCommand). I want this sub to load another
    template when it sees this CommandName.

    The problem I have is that when I click down to this level, I get
    "BC30002: Type 'DataListCommandEventArgs' is not defined" on the
    subroutine. I've tried adding a declaration for
    System.Web.UI.WebControls.CommandEventArgs in both the template's html
    and the code-behind where the sub is, which didn't work.

    Any ideas? I would think I should be able to do this.

    Thanks,
    Barry

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Barry, Aug 6, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DotNetGuru

    Handling Events in Nested Controls

    DotNetGuru, Jun 26, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    502
    Todd Thompson
    Jun 26, 2003
  2. luca
    Replies:
    2
    Views:
    498
  3. newbye
    Replies:
    0
    Views:
    593
    newbye
    Jul 6, 2006
  4. SevDer
    Replies:
    2
    Views:
    1,333
    Walter Wang [MSFT]
    Nov 13, 2007
  5. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    423
    Chris
    Aug 30, 2005
Loading...

Share This Page