p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 2.0 Databases Beta Preview
This is the forum to discuss the Wrox book Beginning ASP.NET 2.0 Databases: Beta Preview by John Kauffman, Thiru Thangarathinam; ISBN: 9780764570810

Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 2.0 Databases Beta Preview section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 24th, 2005, 01:50 PM
Registered User
 
Join Date: May 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default cascading templated dropdowns

Ch 9 #10 ... works fine in regular dropdowns but does not work when the two dropdowns are cascading ??? ...

"Could not find control <name of the first dropdown> in ControlParameter <name of the parameter>"

Am I missing something???

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
  #2 (permalink)  
Old May 26th, 2005, 06:38 PM
Registered User
 
Join Date: May 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I found the answer to my problem:

Move the DataSource declaration inside of the DetailsView InsertTemplate field which has a DropDown that's referencing that DataSource's Id and it'll be able to find controls within the details view.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
  #3 (permalink)  
Old February 16th, 2006, 12:02 AM
Registered User
 
Join Date: Feb 2006
Location: Silver Spring, Maryland, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by rickr48
 I found the answer to my problem:

Move the DataSource declaration inside of the DetailsView InsertTemplate field which has a DropDown that's referencing that DataSource's Id and it'll be able to find controls within the details view.

I am having the same problem. However, your solution works only if you only need that DataSource for just one control. If you need it for multiple controls that are in other containers then if you encapsulate it within one container then it will not be able to be seen by controls referencing it from other containers. I don't want to have redundant DataSources but I don't see a way around it. This is obviously a bug in the .NET Framework.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
  #4 (permalink)  
Old March 1st, 2006, 06:05 AM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello,
Here is a solution : as Microsoft's ControlParameter cannot find bound control if it's in another container, I created my own parameter, overriding the "Evaluate" method.

using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;
using System.Web.UI;
using System.Reflection;
using System.Web;

namespace ...
{
    public class CrossContainerControlParameter : ControlParameter
    {
        /// <summary>
        /// Updates and returns the value of the <see cref="T:System.Web.UI.WebControls.ControlParameter "></see> object.
        /// </summary>
        /// <param name="context">The current <see cref="T:System.Web.HttpContext"></see> of the request.</param>
        /// <param name="control">The <see cref="T:System.Web.UI.Control"></see> that the parameter is bound to.</param>
        /// <returns>
        /// An <see cref="T:System.Object"></see> that represents the updated and current value of the parameter.
        /// </returns>
        /// <exception cref="T:System.ArgumentException">The <see cref="P:System.Web.UI.WebControls.ControlParameter .ControlID"></see> property is not set.- or -The <see cref="P:System.Web.UI.WebControls.ControlParameter .PropertyName"></see> property is not set and the <see cref="T:System.Web.UI.Control"></see> identified by the <see cref="P:System.Web.UI.WebControls.ControlParameter .ControlID"></see> property is not decorated with a <see cref="T:System.Web.UI.ControlValuePropertyAttribut e"></see> attribute. </exception>
        /// <exception cref="T:System.InvalidOperationException"><see cref="M:System.Web.UI.Control.FindControl(System.S tring)"></see> does not return the specified control.- or -The control identified by the <see cref="P:System.Web.UI.WebControls.ControlParameter .ControlID"></see> property does not support the property named by <see cref="P:System.Web.UI.WebControls.ControlParameter .PropertyName"></see>. </exception>
        protected override object Evaluate(System.Web.HttpContext context, System.Web.UI.Control control)
        {
            if (control == null) return null;
            if (control.Page == null) return null;


            Control c = this.FindControlInContainer(control.Page);
            if (c==null)
                throw new HttpException("Control '" + ControlID + "' not found.");
            PropertyInfo prop = c.GetType().GetProperty(PropertyName);
            if (prop == null) throw new HttpException("Property '" + PropertyName + "' not found in type '" + c.GetType() + "'.");

            return prop.GetValue(c, null);

        }

        /// <summary>
        /// Finds the control in container.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="controlId">The control id.</param>
        /// <returns></returns>
        private Control FindControlInContainer(Control container, string controlId)
        {
            if (container.FindControl(controlId) != null)
                return container.FindControl(controlId);
            foreach (Control c in container.Controls)
            {
                Control controlFound = FindControlInContainer(c, controlId);
                if (controlFound != null)
                    return controlFound;
            }
            return null;
        }


    }
}

Used in my page as follow :
<asp:ObjectDataSource ID="ObjectDataSource2" runat="server" SelectMethod="..." TypeName="...">
            <SelectParameters>
                <cc1:CrossContainerControlParameter ControlID="GridView1" DefaultValue="..." Name="shortName"
                    PropertyName="SelectedValue" Type="String" />
            </SelectParameters>
        </asp:ObjectDataSource>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
  #5 (permalink)  
Old March 9th, 2006, 01:15 AM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Refer to the control parameter like this:
FormView1$DropDownlist1

This is a much easier solution.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
  #6 (permalink)  
Old September 7th, 2006, 12:09 AM
Registered User
 
Join Date: Sep 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I added "Container's ID"+"$" before ControlID already but problem still exist. did you solved the broblem?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
  #7 (permalink)  
Old September 10th, 2006, 06:39 PM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Part of the fix to this problem is finding the ID the nested control is given at runtime.

Apply the trace attribute to your page then run it. Scroll through control hierarchy and you should find the control you're dealing with, Pay attention to the system made ID.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
 


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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 6: Templated Controls In Design View geomar BOOK: Professional ASP.NET 2.0 Server Control and Component Development ISBN: 978-0-471-79350-2 1 February 20th, 2007 12:23 PM
Ch 6 Templated Controls geomar BOOK: Professional ASP.NET 2.0 Server Control and Component Development ISBN: 978-0-471-79350-2 2 February 3rd, 2007 07:58 PM
Cascading dropdowns-Client Callbacks spriya18 ASP.NET 2.0 Professional 0 December 29th, 2005 02:29 PM
Access templated controls properties tony_j_hug ASP.NET 2.0 Basics 5 October 17th, 2005 11:44 AM
Templated Datagrid Checkbox column .. Help Require wak BOOK: ASP.NET Website Programming Problem-Design-Solution 0 October 20th, 2003 05:30 AM



All times are GMT -4. The time now is 02:26 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc