raise a bubble event.

Discussion in 'ASP .Net' started by Lucifer, Oct 13, 2004.

  1. Lucifer

    Lucifer Guest

    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
    Lucifer, Oct 13, 2004
    #1
    1. Advertising

  2. Lucifer

    Scott Allen Guest

    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,

    --
    Scott
    http://www.OdeToCode.com/blogs/scott/

    On 13 Oct 2004 07:34:13 -0700, "Lucifer" <> wrote:

    >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
    Scott Allen, Oct 13, 2004
    #2
    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. Lucifer

    raise a bubble event.

    Lucifer, Oct 13, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    408
    Lucifer
    Oct 13, 2004
  2. Jacol

    raise or not to raise [Newbie]

    Jacol, Feb 3, 2007, in forum: Python
    Replies:
    5
    Views:
    402
    Gabriel Genellina
    Feb 5, 2007
  3. mlimber
    Replies:
    0
    Views:
    791
    mlimber
    Aug 5, 2008
  4. ernest
    Replies:
    2
    Views:
    285
    Roy Smith
    Nov 14, 2010
  5. Lucifer

    raise a bubble event.

    Lucifer, Oct 13, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    98
    Lucifer
    Oct 13, 2004
Loading...

Share This Page