Solved

AJAX cascadingDropDown SelectedValue bind Issue

Posted on 2008-06-24
1
718 Views
Last Modified: 2008-07-01
I have a CascadingDropDown  on my page and it works fine but when I Bind it to my SqlDataSource and try to update the database it throws an error. Aftersome research into the problem I found that the CascadingDropDown  Selectedvalue was returning DATAID:::DATAVALUE. With DATAID being the ID and DAVALUE being what shows in the DDL. So how do I get just the ID to Bind and not the rest. I have included the DDL and CDD just in case I messed up somewhere.

Thank You
<asp:DropDownList ID="DDLCat" runat="server" Width="199px" />

<cc1:CascadingDropDown ID="cddCertCat"  

runat="server"

TargetControlID="DDLCat" 

Category="Cat"

ServicePath="CertCatService.asmx"

ServiceMethod="GetCertCat"

SelectedValue='<%# Bind("CERTCATID") %>'

 /> 

[WebMethod]

    public CascadingDropDownNameValue[] GetCertCat(string knownCategoryValues, string category)

    {
 

        dsCertCatTableAdapters.TBLCERTCATTableAdapter catAdapter = new dsCertCatTableAdapters.TBLCERTCATTableAdapter();

        dsCertCat.TBLCERTCATDataTable cat = catAdapter.GetCertCat();

        List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();

        foreach (DataRow dr in cat)

        {

            string CatDesc = (string)dr["CERTCATDESC"];

            int CATID = (int)dr["CERTCATID"];

            values.Add(new CascadingDropDownNameValue(CatDesc, CATID.ToString()));

        }

        return values.ToArray();

    }

Open in new window

0
Comment
Question by:NoSleepForTheWeary
1 Comment
 

Accepted Solution

by:
NoSleepForTheWeary earned 0 total points
ID: 21909379
I found a simple solution today. Apparently when trying to bind a cascadingdropdownbox  to a sql data source you have to bind the dropdownbox and eval the CDD as follows. Not sure why it works but it does and that is all I care about. :)

<asp:DropDownList ID="DDLCat" runat="server" Width="199px"  DataSourceID="SqlDataSource2" DataTextField="CERTCATDESC" DataValueField="CERTCATID" SelectedValue='<%# Bind("CERTCATID") %>' />

<cc1:CascadingDropDown ID="cddCertCat"  runat="server"TargetControlID="DDLCat" Category="Cat" PromptText="Please select a Category"ServicePath="CertCatService.asmx"ServiceMethod="GetCertCat"SelectedValue='<%# Eval("CERTCATID") %>'  
/>

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Registering DLL 5 43
Jquey and footrable 2 34
Getting multiple values from a dataset ASP.NET(VB) 3 37
PHP - AJAX and MySQL it works only if the value is a number 12 33
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now