findcontrol to find in nested datalists

Discussion in 'ASP .Net' started by Greg Fischer, Nov 15, 2004.

  1. Greg Fischer

    Greg Fischer Guest

    I need to access the properties of a control that is nested in 2 datalists.
    How do you use findcontrol method to do that?

    what I have is like this:

    <asp:datalist id="dlist" runat="server">
    <edititemtemplate>
    <asp:datalist id="dlistdet" runat="server">
    <asp:dropdownlist id="ddlTypes" runat="server"></dropdownlist>
    </asp:datalist>
    </edititemtemplate>
    </asp:datalist>


    Every thing loads fine. The ddlTypes is loaded from a database and I
    can see it's results. I need to access the selected value on it
    directly. I am able to access a control from within the first dlist by
    using:

    neededitem = CType(e.Item.FindControl("controlname"), TextBox)

    But what is the syntax to drill down further into that edititemtemplate
    and the dlistdet? Also, I am running this from the event
    SelectedIndexChanged
    on the dropdownlist, and I dont have the e.item.findcontrol. what I am
    trying is something like this:

    Dim ddl As DropDownList =
    CType(dlist.Items(dlist.SelectedIndex).FindControl("ddlTypes"),
    DropDownList)

    But that isnt working. Not sure what it's supposed to look like.

    Thank you for the assistance!

    Greg Fischer
    1st Byte Solutions
    http://www.1stbyte.com
    Greg Fischer, Nov 15, 2004
    #1
    1. Advertising

  2. Greg Fischer

    Scott Allen Guest

    Hi Greg:

    You are using this from the SelectedIndexChanged event? If so, the
    sender parameter is the DropDownList control, you'll just need to
    CType it into a DropDownList and then start party.

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

    On Mon, 15 Nov 2004 15:57:37 -0800, Greg Fischer
    <> wrote:

    >I need to access the properties of a control that is nested in 2 datalists.
    >How do you use findcontrol method to do that?
    >
    >what I have is like this:
    >
    ><asp:datalist id="dlist" runat="server">
    > <edititemtemplate>
    > <asp:datalist id="dlistdet" runat="server">
    > <asp:dropdownlist id="ddlTypes" runat="server"></dropdownlist>
    > </asp:datalist>
    > </edititemtemplate>
    ></asp:datalist>
    >
    >
    >Every thing loads fine. The ddlTypes is loaded from a database and I
    >can see it's results. I need to access the selected value on it
    >directly. I am able to access a control from within the first dlist by
    >using:
    >
    >neededitem = CType(e.Item.FindControl("controlname"), TextBox)
    >
    >But what is the syntax to drill down further into that edititemtemplate
    >and the dlistdet? Also, I am running this from the event
    >SelectedIndexChanged
    >on the dropdownlist, and I dont have the e.item.findcontrol. what I am
    >trying is something like this:
    >
    >Dim ddl As DropDownList =
    >CType(dlist.Items(dlist.SelectedIndex).FindControl("ddlTypes"),
    >DropDownList)
    >
    >But that isnt working. Not sure what it's supposed to look like.
    >
    >Thank you for the assistance!
    >
    >Greg Fischer
    >1st Byte Solutions
    >http://www.1stbyte.com
    Scott Allen, Nov 16, 2004
    #2
    1. Advertising

  3. Greg Fischer

    Greg Fischer Guest

    Ah, yes! That's right. thanks!

    this was it...

    Public Sub cmbAddType_OnSelect(ByVal s As System.Object, ByVal e As
    System.EventArgs) Handles cmbAddType.SelectedIndexChanged

    Dim ddl As DropDownList = CType(s, DropDownList)

    From there I have all the properties!

    Cool!
    Greg Fischer, Nov 16, 2004
    #3
    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. Marty U.

    nested datalists event bubble

    Marty U., Dec 1, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    423
    Marty U.
    Dec 1, 2004
  2. Sparky Arbuckle

    Nested Datalists

    Sparky Arbuckle, Aug 24, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    4,495
    Sparky Arbuckle
    Aug 24, 2005
  3. schapopa
    Replies:
    0
    Views:
    678
    schapopa
    Jan 5, 2006
  4. schapopa
    Replies:
    0
    Views:
    385
    schapopa
    Jan 5, 2006
  5. jobs
    Replies:
    2
    Views:
    1,213
    David Wier
    Oct 16, 2006
Loading...

Share This Page