Showing posts with label dropdowns. Show all posts
Showing posts with label dropdowns. Show all posts

Monday, March 26, 2012

CascasCadingDropdown problem

I have a ccd with 3 dropdowns in it, with 2 of the dropdowns(ddlLocatie and ddlPersoon) beingdependant on the first one (ddlAfdeling). I set the selectedvaluepropertydynamically when the page loads. I usecddAfdLoc.TargetProperties(0).SelectedValue = <variable> to dothis. The ddl's are getting their values from a database.

The issue i have is the following: ddlLocatie doesn't want topopulate while ddlPersoon populates just fine when the pageloads. When i select another value manually from ddlAfdeling,everything populates without problems. If i don't set it dynamicallyand simply select manually after the page has loaded everything worksfine, both ddlLocatie and ddlPersoon get enabled and populated. Is what i'm trying to do not supported maybe?

<%@dotnet.itags.org. Page Language="VB" EnableEventValidation="false" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@dotnet.itags.org. Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit" TagPrefix="atlasToolkit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<atlas:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<p>
Afdeling:<br />
<asp:DropDownList ID="ddlAfdeling" runat="server" Width="205px">
</asp:DropDownList>
</p>
<p>
Locatie: <br />
<asp:DropDownList ID="ddlLocatie" runat="server" Width="205px">
</asp:DropDownList>
</p>
<p>Gebruiker:<br /><asp:DropDownList ID="ddlPersoon" runat="server" Width="205px">
</asp:DropDownList>
</p>
<atlasToolkit:CascadingDropDown ID="cddAfdLoc" runat="server">
<atlasToolkit:CascadingDropDownProperties TargetControlID="ddlAfdeling" Category="afdeling" PromptText="kies" ServicePath="wsTD.asmx" ServiceMethod="GetAfd" />
<atlasToolkit:CascadingDropDownProperties TargetControlID="ddlLocatie" Category="locatie" PromptText="kies" ServicePath="wsTD.asmx" ServiceMethod="GetLocatie" ParentControlID="ddlAfdeling" />
<atlasToolkit:CascadingDropDownProperties TargetControlID="ddlPersoon" Category="persoon" PromptText="kies" ServicePath="wsTD.asmx" ServiceMethod="GetPers" ParentControlID="ddlAfdeling" />
</atlasToolkit:CascadingDropDown>
</div>
</form
</body>
</html>

Yes, I think this will be supported withwork item 1704.
Great, thx a lot :)
Note that I checked a fix for this in on Friday. It should be available in CodePlex changes 3611 and later. If you want to give it a try, I'd love to know if that change doesn't work for you!

Hello David,

Sorry for the late reply, i've only now been able to get back to this.

I've been looking through the CascadingDropDown.js file and was only able to locate

_parentElement.childDropDown = this

on line 57, not on line 61 like it said in the post.

also, i could not locate this piece of code to change

if (e.childDropDown && !gettingList) {
e.childDropDown._onParentChange();
}
Is this in a different js file or am i using a different version from him? I've got the July CTP installed.

Sounds like you have a different version, perhaps. I believe my code changes can be applied to the code that ships with the 60731 release of the Toolkit. Alternatively, any of the recent development releases should already have the changes in them.

Where could i check the version number?

I'll download the latest dev release as well.


The version number should be on the default page of the SampleWebSite. You can get recent development releaseshere.

cascadingdropdowns when only one listitem

I am happily using cascading dropdowns for a three-level stack. In some cases, there is only one item in the generated list apart from the select prompt. Common sense and good design suggests that the one item should be auto-selected but this has not been implemented in the Toolkit.

I tried to implement it by setting the selected attribute (third parameter) to 'true' in the Web service. This worked for the displayed ddl, but the underlying value was not set . Hence the next level in the dropdown failed because no value was supplied.

Is this a bug or am I doing something wrong?

The relevant line in the VB Web Service (PageMethod) is:

values.Add(

New CascadingDropDownNameValue(sCompany, sCompanyId,True))

If I do not use the third parameter, I get the standard result with my Prompt showing in the ddl, and everything working when I actually select the one item.

This sounds like a bug. Could you whip up a quick sample page demonstrating the problem and file the issue at CodePlex?

http://www.codeplex.com/WorkItem/List.aspx?ProjectName=AtlasControlToolkit

Thanks!

Saturday, March 24, 2012

CascadingDropDownList and ModalPopupExtender

I have created a ModalPopupExtender that contains 3 CascadingDropDownLists. The dropdowns work and are populated normally if I don't try and set a value. If I try and set a value for the first dropdown I get an ArgumentOutOfRangeException error. It seems like the value is trying to be set before the dropdown is populated. Does anyone know how I can fix this?

Thanks.

Nevermind. I got it.

CascadingDropdownList [Method Error 500]

Still trying to get these dropdowns to work. I have created a page with a single ddl that should be populated from the web service and has no parents but I still get the [method error 500] as the values, what am I mising here?

ddl.aspx

<%@dotnet.itags.org. Page Language="VB" AutoEventWireup="false" %>
<%@dotnet.itags.org. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@dotnet.itags.org. Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager id="ScriptManager1" runat="server" EnablePartialRendering="true" >
</asp:ScriptManager>

<asp:DropDownList ID="Region" runat="server" >
</asp:DropDownList>

<cc1:CascadingDropDown
Category="Region"
Enabled="true"
PromptText="Please work..."
ID="CascadingDropDown2"
TargetControlID="Region"
ServiceMethod="GetCountries"
ServicePath="CountriesByRegion.asmx"
runat="server">
</cc1:CascadingDropDown>

</form>
</body>
</html>

CountriesByRegion.asmx

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports PFCEnergy.Refining.Country.Business
Imports System.Data
Imports AjaxControlToolkit

<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<System.Web.Script.Services.ScriptService()> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class CountriesByRegion
Inherits System.Web.Services.WebService

<WebMethod()> _
Public Shared Function GetCountries(ByVal knownCategoryValues As String, ByVal category As String) As CascadingDropDownNameValue()
Dim values As New _
System.Collections.Generic.List( _
Of AjaxControlToolkit.CascadingDropDownNameValue)

values.Add(New CascadingDropDownNameValue("foo", "bar"))
values.Add(New CascadingDropDownNameValue("bar", "foo"))
Return values.ToArray
End Function

End Class

Hi,

I too get the same error . Have you sorted the problem ?

Pls help if its working for u .

Thanks.


Yeah got it working, I added the bold and removed the struck through. Good luck.

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Collections.Generic
Imports System.Data
Imports AjaxControlToolkit

<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<System.Web.Script.Services.ScriptService()> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class CountriesByRegion
Inherits System.Web.Services.WebService

<WebMethod()> _
PublicShared Function GetCountries(ByVal knownCategoryValues As String, ByVal category As String) As CascadingDropDownNameValue()
Dim values As New _
System.Collections.Generic.List( _
Of AjaxControlToolkit.CascadingDropDownNameValue)

values.Add(New CascadingDropDownNameValue("foo", "bar"))
values.Add(New CascadingDropDownNameValue("bar", "foo"))
Return values.ToArray
End Function

End Class


Hi,

Iam not using list as u did in web method, So i thinkImports System.Collections.Generic is not needed.

Then i am not using Static (C#) in function.

So what would be wrong in my case?

Thanks.



Hi everyone, I had the same problem and after a little tweaking it works!

Here is the tip:

Please make that the database datatype matches the .NET datatype.If you have a different datatype in your database, you should TYPE CAST it to the corresponding .NET type.
string make = (string)dr["Make"];
int makeId = (int)dr["MakeID"];

.NET Framework Type

ADO.NET Database Type

SQL Data Type

String

Varchar

Varchar()

String

Nvarchar

Nvarchar()

String

NChar

Nchar()

String

NText

NText

String

Text

Text

Double

BigInt

Float

DateTime

DateTime

Datetime

DateTime

SmallDateTime

Smalldatetime

Int

Int

Int

Int64

BigInt

Bigint

Int16

SmallInt

smallint

Byte[]

Binary

Binary()

Byte[]

Image

Image

Byte[]

VarBinary

Varbinary()

Byte

TinyInt

Tinyint

Bool

Bit

Bit

Decimal

Decimal

Decimal

Decimal

Money

Money

Decimal

SmallMoney

SmallMoney

Float

Float

Float

Guid

UniqueIdentifier

Uniqueidentifier

Real

Real

Real

CascadingDropDown setting SelectedValue programmatically doesnt work

Hi

I have a page which has four dropdowns "linked" together via CascadingDropDown Extenders.

The page works fine, except that I sometimes want the dropdowns to be pre-populated and specific items selected programmatically.

e.g.

1cddlMakes.SelectedValue = cmk.Vehicle.Make.ID2cddlModels.SelectedValue = cmk.Vehicle.Model.ID3cddlTypes.SelectedValue = cmk.Vehicle.Type.ID4cddlEngines.SelectedValue = cmk.Vehicle.Engine.ID

The first 2 dropdowns load and display the correct selected value, but the other two dropdowns SelectedValues don't get set and stay on the "Please Select..." option.

Any ideas?

Using the sample page, I have no issue programmatically setting any of the 3 cascading drop down extenders' selected value. Are you setting the extenders or the controls?
12 CascadingDropDown1.SelectedValue ="Acura";3 CascadingDropDown2.SelectedValue ="Integra";4 CascadingDropDown3.SelectedValue ="Green";

Wednesday, March 21, 2012

CascadingDropDown question

I have weird problem with CascadingDropDown. I have user control with two dropDowns. If I get into this page through Select Class -> Select Category pages I set

CascadingDropDown1.Enabled =false (and so on for all of them)
and use query string to populate DDLs and set selected value. Or I can directly get into this page and use CascadingDropDown since I don't have query string.

But it doesn't work this way. When I get into this page through Select Class -> Select Category pages everything is fine, but after first postback ddl's datasources are empty.

If I completely remove CascadingDropDown definition from code - it works OK.

Any idea why this happens? Not sure, probably I'm missing something or it's CascadingDropDown bug.

Thanks.

Vladimir.

Hi Vladimir,

Can you elaborate what do you mean by "Select Class -> Select Category pages" ?

I don't quite understand your problem.


Thanks very much for the replay.

I mean that I have on the page two DropDownLists. First I select Class then by this Class i can select Category. After I select Category I'm able to populate GridView.

On this page I can get either through direct link (in this case I don't have data for Class and Category and wanted to use CascadingDropDown) or I can go first on the page SelectClass. Then on the page SelectCategory which will move to the page where I'll have Class and Category already selected and available in the query string in the url address.

This is basically what I wanted.

CascadingDropDown problem with the v1.0 version

Hi all,

in one of my pages, i have two dropdowns: one for listing countries and the second for listing the states/provinces of the country selected in the first one dropdown.

When i was using the AJAX Release candidate version, I used the cascadingdropdown without problem. But when i installed the v1.0, the cascadingdropdown stop updating the second dropdown, as used to. Is there someone who can tell me what i am doing wrong?

Part of my code in the aspx file:

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel id="UpdatePanel1" runat="server" UpdateMode="Conditional" RenderMode="Inline">
<ContentTemplate>

<TABLE style="WIDTH: 100%; TEXT-ALIGN: left">
<TBODY> <TR>
<TD style="WIDTH: 328px; TEXT-ALIGN: left">
<asp:DropDownList id="CountryDropDownList" tabIndex=12 runat="server" Width="204px" AutoPostBack="True" DataTextField="Name" DataValueField="Id"></asp:DropDownList>
</TD>

<TD style="WIDTH: 328px; HEIGHT: 24px; TEXT-ALIGN: left">
<asp:DropDownList id="ProvinceDropDownList" tabIndex=12 runat="server" Width="204px" DataTextField="Name" DataValueField="Id"></asp:DropDownList>
</TD>
</TBODY>
</TABLE>

<cc1:CascadingDropDown id="CascadingDropDown1" runat="server" TargetControlID="CountryDropDownList" Category="Country" ServicePath="CustomerSignUp.aspx" ServiceMethod="GetAllCountries" PromptText="<%$ Resources:Messages, SelectCountry %>" LoadingText="<%$ Resources:Messages, Loading %>"></cc1:CascadingDropDown>

<cc1:CascadingDropDown id="CascadingDropDown2" runat="server" TargetControlID="ProvinceDropDownList" Category="Province" ServicePath="CustomerSignUp.aspx" ServiceMethod="GetCountryProvinces" PromptText="<%$ Resources:Messages, SelectProvince %>" LoadingText="<%$ Resources:Messages, Loading %>" ParentControlID="CountryDropDownList"></cc1:CascadingDropDown>

</ContentTemplate>
</asp:UpdatePanel>

</asp:Content>

Methods in the aspx.cs file:

[WebMethod]
public static CascadingDropDownNameValue[] GetAllCountries(string knownCategoryValues, string category)
{
List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();
ICollection<Country> countries = KinocastFacade.Instance.GetAllCountries();
foreach (Country country in countries)
{
values.Add(new CascadingDropDownNameValue(
Resources.Messages.ResourceManager.GetString(country.Name), country.Id.ToString()));
}

return values.ToArray();

}

[WebMethod]
public static CascadingDropDownNameValue[] GetCountryProvinces(string knownCategoryValues, string category)
{
StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(
knownCategoryValues);
int countryId;

/*Verifica se a chave country está no StringDictionary e se é possivel
*fazer o parse do seu valor para inteiro. Se possivel coloca o valor
*em countryId*/
if (!kv.ContainsKey("Country") ||
!Int32.TryParse(kv["Country"], out countryId))
{
return null;
}

List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();
ICollection<Province> provinces = KinocastFacade.Instance.GetCountryProvinces(countryId);
foreach (Province province in provinces)
{
values.Add(new CascadingDropDownNameValue(
Resources.Messages.ResourceManager.GetString(province.Name), province.Id.ToString()));
}

return values.ToArray();
}

Thanks a lot for any help,

Rodrigo

Anyway,

I've just resolved my problem re-creating the project, including all my files and modules again. And at the end, i include the AjaxControlToolkit.dll (version 1.0.10301.0) and the cascadingdropdown problem disapeared.

Maybe, it had happened because the VS saves some olds DLLs in a limbo place :p ...... I dont know...

Cheers.