raise a bubble event.

L

Lucifer

Hi

I am trying to raise a bubble event.

I have a dropdownlist and a datalist in a datalist.

I want to use the postback from the dropdownlist to rebind the nested
datalist. But i need the event to be a datalist Command so i have
access to e.item for the main datalist

the aspx code

<asp:datalist id=PostageGroups
OnSelectedIndexChanged="ddlGroupStatus_SelectedIndexChanged"
AutoPostBack="True" ' etc...
<ItemTemplate>
'my dropdown for picking the status
'of the items to be listed in
<asp:dropdownlist id=ItemStatus ...
</asp:dropdownlist>
'nested datalist
<asp:datalist id=PostageItems
'some more code...
</asp:datalist:asp>
</ItemTemplate>
</asp:datalist>

i am trying to catch the datalist PostageGroups postback for the
dropdownlist ItemStatus so i can rebind the rested datalist

the aspx.vb code:

Public Event Command As
System.Web.UI.WebControls.CommandEventHandler

Protected Overridable Sub OnCommand(ByVal e As
System.Web.UI.WebControls.CommandEventArgs, ByVal source As Object)

RaiseEvent Command(source, e)

RaiseBubbleEvent(source, e)

End Sub

Public Sub ddlGroupStatus_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs)

OnCommand(New
System.Web.UI.WebControls.CommandEventArgs("DropDown", CType(sender,
DropDownList).SelectedValue), CType(sender, DropDownList))

End Sub

Private Sub PostageTypes_ItemCommand(ByVal source As Object,
ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles
PostageTypes.ItemCommand

If e.CommandName = "DropDown" Then

Dim GroupID As Integer =
CType(CType(e.Item.FindControl("lblDeliveryGroupID"), Label).Text,
Integer)
Dim Status As Boolean =
CBool(CType(e.Item.FindControl("ddlGroupStatus"),
DropDownList).SelectedValue)
Dim myPostage As New Ecom_PostageDB

With CType(PostageTypes.FindControl("PostageList"),
DataList)
..SelectedIndex = -1
..DataSource =
myPostage.GetPostageItemsByStatusAndGroup(Status, GroupID)
..DataBind()
End With

End If
 
S

Scott Allen

Hi Lucifer,

When the DropDownList fires a SelectIndexchanged event, the sender
parameter in the event handler will represent the DropDownList. You
can use the Parent property of the DropDownList to get back to the
DataListItem, and from there grab the nested DataList (perhaps with
FindControl).

I have two articles that could help you. They deal with DataGrid and
Repeaters, but the approach is the same.

DropDownList Controls In an ASP.Net DataGrid
http://odetocode.com/Articles/231.aspx

In Search Of ASP.NET Controls
http://www.odetocode.com/Articles/116.aspx

HTH,
 

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,982
Messages
2,570,185
Members
46,737
Latest member
Georgeengab

Latest Threads

Top