Solved

AJAX cascadingDropDown SelectedValue bind Issue

Posted on 2008-06-24
1
724 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

840 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