Solved

AJAX cascadingDropDown SelectedValue bind Issue

Posted on 2008-06-21
5
1,559 Views
Last Modified: 2013-11-26
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") %>'
 />

Open in new window

0
Comment
Question by:NoSleepForTheWeary
  • 2
  • 2
5 Comments
 
LVL 33

Expert Comment

by:raterus
ID: 21851124
For one, this is an asp.net question and should be put in the asp.net zone, this is likely why you were receiving no responses.

I don't see where you are setting the DataTextField and DataValueField of the DropDownList.  Are these being set somewhere else?  
0
 

Author Comment

by:NoSleepForTheWeary
ID: 21852953
yes as far as I know this is the code that sets the DataTextField and DataValueField
[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();
    }

as per this instruction

http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Walkthrough/CCDWithDB.aspx
0
 

Author Comment

by:NoSleepForTheWeary
ID: 21852966
P.S. Sorry I didnt add to the ASP.NET but not sure how to change it now lost my edit capability
TY
0
 
LVL 33

Accepted Solution

by:
raterus earned 500 total points
ID: 21855321
Sorry, I really don't know then.  I would suggest deleting this question and ask it again in the ASP.Net Zone, you should get much more experts to look at your question this time!
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

713 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