Solved

AJAX cascadingDropDown SelectedValue bind Issue

Posted on 2008-06-24
1
732 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

728 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