Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 11th, 2006, 09:35 AM
Registered User
Join Date: Sep 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default selected value of nested repeater-build <select>

i have a drop down list (a <select> element) constructed with a repeater nested within a repeater so that i can use <optgroup>s.

<asp:Repeater ID="rptIssuesNotInRelease" runat="server" DataSourceID="sdsSectionsNotInRelease">
        <select id="ddlIssuesNotInRelease">
        <asp:HiddenField Value='<%# Eval("SectionID") %>' ID="hidSectionID" runat="server" Visible="false"/>
        <optgroup label='<%# Eval("Name") %>'>

            <asp:Repeater ID="rptIssuesInSection" runat="server" DataSourceID="sdsIssuesInSection">
                    <option value='<%# Eval("IssueID") %>'><%# (Eval("Problem").ToString().Length > 100 ? Eval("Problem").ToString().Substring(0, 100) + "..." : Eval("Problem")) %></option>

the code it produces is something like (picture this as a drop down list with groups):

+ Section 1 +
   Item A
   Item B
+ Section 2 +
   Item C
   Item D

whichever item my user selects, i need to get the value of that selected item. trying to use FindControl inside my "add to release" button event produces a null control.

System.Web.UI.HtmlControls.HtmlSelect ddlIssuesNotInRelease = (System.Web.UI.HtmlControls.HtmlSelect)rptIssuesNotInRelease.FindControl("ddlIssuesNotInRelease");

what i am missing? how can i access the value of my drop down list during my button click event? am i creating optgroups with asp all wrong?
  #2 (permalink)  
Old September 12th, 2006, 09:01 AM
Friend of Wrox
Join Date: Feb 2006
Location: , , USA.
Posts: 116
Thanks: 0
Thanked 0 Times in 0 Posts

The reason you can not find this control on the server side is that you have used a server side control (a repeater) to simply print out a client side select box to the client tier. You named that client side select box "ddlIssuesNotInRelease" but in reality there is no "ddlIssuesNotInRelease" control on the server, thus there is nothing for that select box to post back to. ddlIssuesNotInRelease only exists in the client tier as you have it now.

I am pretty sure you don't want to be using a repeater to do this. I am not quite sure what to recommend but you definitely need to use a server side control if you need to post back and access the control on the server side.

Neil Timmerman
Veris Consulting
  #3 (permalink)  
Old September 15th, 2006, 09:52 AM
Registered User
Join Date: Sep 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

while that's not the answer i was hoping for, it's the answer i feared i'd get. "Connect" from the asp forums [1] was able to point me to a different way of getting optgroups into my page while still being able to access the value of the select. perhaps someone else will find it useful.

thanks very much for the reply. :) maybe i'll be more fortunate in asp 3.

[1] http://forums.asp.net/thread/1395549.aspx

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
nested <div> creates extra space sstuber BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 May 2nd, 2008 09:56 AM
syntax error on <option selected="selected"> hamid HTML Code Clinic 1 October 13th, 2004 09:20 AM
HELP: XSL -> HTML <select selected=true> jedbartlett XSLT 4 October 7th, 2004 11:16 PM

All times are GMT -4. The time now is 10:00 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.