Handling events in container controls?

B

Barry

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top