Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > findcontrol to find in nested datalists

Reply
Thread Tools

findcontrol to find in nested datalists

 
 
Greg Fischer
Guest
Posts: n/a
 
      11-15-2004
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
 
Reply With Quote
 
 
 
 
Scott Allen
Guest
Posts: n/a
 
      11-16-2004
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).FindContro l("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


 
Reply With Quote
 
 
 
 
Greg Fischer
Guest
Posts: n/a
 
      11-16-2004
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!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Collapsible Nested Datalists ? Findcontrol by Value? jobs ASP .Net 2 10-16-2006 10:05 PM
Nested datalists and width property of TD schapopa ASP .Net 0 01-05-2006 01:13 PM
Nested datalists and width property of TD schapopa ASP .Net 0 01-05-2006 01:07 PM
Nested Datalists Sparky Arbuckle ASP .Net 5 08-24-2005 09:56 PM
nested datalists event bubble Marty U. ASP .Net 0 12-01-2004 12:45 AM



Advertisments