|
|
 |
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.
|

May 24th, 2005, 01:50 PM
|
|
Registered User
|
|
Join Date: May 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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???
|

May 26th, 2005, 06:38 PM
|
|
Registered User
|
|
Join Date: May 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|

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
|
|
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.
|

March 1st, 2006, 06:05 AM
|
|
Registered User
|
|
Join Date: Mar 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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>
|

March 9th, 2006, 01:15 AM
|
|
Registered User
|
|
Join Date: Mar 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Refer to the control parameter like this:
FormView1$DropDownlist1
This is a much easier solution.
|

September 7th, 2006, 12:09 AM
|
|
Registered User
|
|
Join Date: Sep 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I added "Container's ID"+"$" before ControlID already but problem still exist. did you solved the broblem?
|

September 10th, 2006, 06:39 PM
|
|
Registered User
|
|
Join Date: Jan 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |