Solved

AJAX cascadingDropDown SelectedValue bind Issue

Posted on 2008-06-24
1
712 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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
WPF issue with Trigger 2 65
javascript call 6 35
(code works) but print excel in Landscape 5 49
Asp/Net Validation date Issue 9 36
OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

772 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

11 Experts available now in Live!

Get 1:1 Help Now