How to take selected value of dropdownlist in web method using cascading dropdownlist

Hi All,

I am using C# asp.net 2.0 and ajax1.0.I am trying to fill dropdownlist using ajax cascading toolkit but I am not able to populate the dropdownlist.  My question is how do I take input value of parent dropdownlist in web service the fill the data that is in my senario I have subprod parent (fill on page load) and then Prod fill on subprod selection.  The web service method I used is

 

public CascadingDropDownNameValue[] GetProd(string knownCategoryValues, string category)
    {

        StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
        string subgrp = null ;
      //  if (!kv.ContainsKey("PGM_GRP_CODE") || !Int32.TryParse(kv["PGM_GRP_CODE"], out subgrp))
        if (!kv.ContainsKey("PGM_GRP_CODE") )
        {
            return null;
        }
     
        DsprdTableAdapters.SPGETPRODUCT_GIVENSUBTableAdapter prd = new DsprdTableAdapters.SPGETPRODUCT_GIVENSUBTableAdapter();
        Dsprd.SPGETPRODUCT_GIVENSUBDataTable prdgrp = prd.GetProd(subgrp);
        List values = new List();
        foreach (DataRow dr in prdgrp)
        {
            values.Add(new CascadingDropDownNameValue((string)dr["PM_PRD_NAME"], dr["PM_PRD_CODE"].ToString()));
        }
        return values.ToArray();

     
    }

and 
cascading toolkit I definded as 

     "cddPROD" 
                                       runat="server" 
                                       TargetControlID="Ddlproduct" 
                                       ParentControlID="Ddlsubdiv" 
                                       Category="Prod" 
                                       PromptText="Choose a Product...." 
                                       LoadingText="Please wait ..." 
                                       ServicePath="../Prod.asmx" 
                                       ServiceMethod="GetProd"> 
 
 
Please suggest.
 
0
mohdimranabdulaziz
4/15/2008 6:23:19 AM
asp.net.ajax-discussion 13973 articles. 1 followers. Follow

1 Replies
1126 Views

Similar Articles

[PageSpeed] 31

Hi,

Thank you for your post! 

Cascading dropdownlist use   StringDictionary kv = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues) to change it into a StringDictionary type ojbect. Here the source code shows how it works:

        public static StringDictionary ParseKnownCategoryValuesString(string knownCategoryValues)
        {
            // Validate parameters
            if (null == knownCategoryValues)
            {
                throw new ArgumentNullException("knownCategoryValues");
            }

            StringDictionary dictionary = new StringDictionary();
            if (null != knownCategoryValues)
            {
                // Split into category/value pairs
                foreach (string knownCategoryValue in knownCategoryValues.Split(';'))
                {
                    // Split into category and value
                    string[] knownCategoryValuePair = knownCategoryValue.Split(':');
                    if (2 == knownCategoryValuePair.Length)
                    {
                        // Add the pair to the dictionary
                        dictionary.Add(knownCategoryValuePair[0].ToLowerInvariant(), knownCategoryValuePair[1]);
                    }
                }
            }
            return dictionary;
        }

Please don't forget to reset your application by saving your web.config file without any modifications before you start your dubugging work. 

Another useful method is:

  1. Right click on your web service name, choose "view in broswer".
  2. Click "GetInstructorsForSchool"
  3. Add "category:selected option value(not text)" as the value of knownCategoryValues and set category to your category name, which was defined in your *.aspx file.   For example knownCategoryValues="school:1"   category ="school";

         cc1:CascadingDropDown ID="CascadingDropDown1" runat="server" TargetControlID="dlSchool"
            Category="School" PromptText="Select a school" ServicePath="WebSerivce/SchoolService.asmx"
            ServiceMethod="GetSchools" LoadingText="Load Text...">

     4.  Click "invoke" button and check if the result is what you want.

This method is usually used to check if your web service works properly.

 Best Regards,


Sincerely,
Jin-Yu Yin
Microsoft Online Community Support
0
Jin
4/22/2008 2:00:39 AM
Reply:

Similar Artilces:

How Select one dropdownlist value using down arrows corresponding other dropdownlist value are select
I am using two dropdownlist box.One is used for country selection. other one is used for state selection.I am using dropdown selectedindexchanged event. when i click country dropdownlist corresponding state is selected in state dropdownlist box. How select the country in country dropdownlist using down arrow keys at the same time corresponding state is select in state dropdown list.R.Karthikeyan   kartmca: How select the country in country dropdownlist using down arrow keys at the same time corresponding state is select in state dropdown list.Generally, we don't implmenet...

how to get SELECTED VALUE of parent dropdownlist to target dropdownlist using cascading
Hi All, I am using C# , asp.net2.0 , Ajax1.0 i am filling dropdownlist using cascading ajax extender. i taken help of ajax site and build a code to fill the control. my question is how do i get parent selected item value. my web service code to fill target value public CascadingDropDownNameValue[] GetProd(string knownCategoryValues , string category) {StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues); //string subgrp ; //int sub1; //if (!kv.ContainsKey("Prod") || !Int32.TryParse(kv["Prod"], out sub1)) //// if (...

DropDownList selected value determines value of second DropDownList
I have a quick question that I'm sure has been addressed before, but I can't seem to find a solution. I have two drop down list fields: startTime and endTime coded as such: <asp:DropDownList id="startTime" runat="server"> <asp:ListItem Value="00:00">12:00 A.M.</asp:ListItem> <asp:ListItem Value="00:30">12:30 A.M.</asp:ListItem> <asp:ListItem Value="01:00">1:00 A.M.</asp:ListItem> <asp:ListItem Value="...

VB.NET
I have a DataGrid (see code at end of my question) with several dropdownlist controls within TemplateColumns for Editing.  For the first 2 ddls in my grid, ddlMedType and ddlMedicationName, I would like to populate ddlMedicationName based on the selecteditem of ddlMedType, but I don't know how to reference this. Thank you for saving me from confusion!!!! Here is my DataGrid code: NOTE: I've bolded the 2 controls that I need help with -- the rest you can really ignore!! ================== <asp:datagrid id="dgMeds" runat="server" OnEditCommand="dgMeds_EditRow" OnUpdateComm...

how to get selected the value of cascading Ajax dropdownlist extendar control after postback.
how to retain value of dropdown list after postback which is extended by ajax cascading dropdownlist extendar. thanks in advance.     Hi, Can you further elaborate your problem? your retain value is for nxt drop down list? how many drop down list you have? normally what we trying to retrieve value from selected dropdown value is Label1.Text=DropdownList1.selectedValue :) Regards, Hideyoshi, hi,i have 2 Ajax dropdownlist Which is filed through web service. one filter the other.the second dropdown has value <-All->,a,bwhen i select a and cl...

how can i use ajax cascading dropdownlist using sqldatabase?
 hello everone.. i want to use Ajax cascading dropdownlist with the data populating from the sqldatabase.well i try to use the example given in this site.but i got lost in the code. how can i accomplish this.?i m very new to ajax.so provide me with the code for this.. thanks.    Check my blog post at http://blog.g9th.com/blog/post/2007/02/Creating-a-CascadingDropDown-using-ASPNET-AJAX.aspx Thanks -Mark post(s) as "Answer" that helped youMark post(s) as "Answer" that helped youElectronic ScrewWebsite||Blog||Dub@i.net...

populating a dropdownlist of states based on selection of country in dropdownlist and populating a dropdownlist of cities based on selection state in state dropdownlist
My code is this but i m not getting states in dropdownlist of states based on selection of country and  cities based on selection of state <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"><title>Untitled Page</title> </head> <...

Change value of textbox based on value from dropdownlist using ajax?
Hello, I want to program an aspx form so that depending on what value you select from a dropdownlist, a textbox gets populated using ajax or javasciprt (client based) I did this already server-side by reading from an SQL data table, but it's annoying because of the page refresh, anyway to do the same thing using ajax or javascript? Look at my code below:   Many thanks ! :)   Sub ddllocations_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddllocations.SelectedIndexChanged Dim strconn As String Dim myConnection As New SqlConnection(strconn) ...

Dropdownlist selected value passes first value in list no matter what value is selected. why ?
 HI . I have a dropdownlist. Databinds ok but when I must pass a value as a Selected value it always passes the first value in the list even if I select another value. I tried to set the ddl to enableviewstate false but it doesn't change anything. Any ideas ? Code below, thanksLoading the ddl:       productCategories = CatalogAdmin.Admin_Product_Categories_NotIn(productId);        for (int i = 0; i < productCategories.Rows.Count; i++)        {       &...

Dropdownlist useing selected value
Hi there,   I have drop down list I am grabbing value from the database and trying to assign it to the drop down list selected value. And I am filling the dropdownlist from the data base with the on form load.the problem if the value comes from the DB not found in the dropdownlist the page threw exception. I need just to ignore the exception and view the page How can I do that? dropdownlist.Selectedvalue =  value comes from DBThank you for your helpsms    Can you post your code?If everything happens for a reason what is the reason for this error? Chec...

Grdiview, 2 dropdownlist, how to change values in Dropdownlist with Ajax
 Hi,  first of all, I'm new to AJAX and searched a lot about my topic, but couldn't find anything.  Let’s describe my situation: I'm writing a Web application to manage the work schedule of the staff. Basically I have a table filled with date, project, subproject, time and additional description. All the data is stored in a mysql database. To show the data I use a Gridview, in this GridView I have two depended dorpdownlists (DDL). If the value of the first DDL changes the content of the second drop dwonlist need to be updated. (Each project has its o...

Cascading Dropdownlist
Hi, I would appreciate some help please! Thanks in advance. I am trying to set the selected value of two cascadingdropdowns. I am using javascript (if someone has a better suggestion I am all ears!). The problem I am having is that the dropdowns don't seem to be loaded by the time I try to set the values. I put in a couple alerts, so that pauses the javascript long enough for the dropdowns to load, then the code works. If I take out the alerts the code no longer works. How should I go about setting the selected value? This is the javascript: <script type="text/javascript"...

DropDownList to DropDownList
I want to take the selected value of DropDownListA and based on that value do a query to the database and populate DropDownListB. For example, DropDownListA contains Entity values. If the user selects entity101 then I call stored procedure where I pass in the entity value, run a select statement and get a list of properties associated with the entity name. I want to take that list and populate DropDownListB. Easy enough to do with ASP.NET using the AutoPostBack. Would be real nice to do this with Atlas. Is it possible? If so, how? Atlas control toolkit has cascading dropdowns-please downlo...

How to populate a second dropdownlist using the value chosen in the first dropdownlist
Hi, I have a problem with 2 drop down list.  I dont' think I can use AJAX cascading drop-down-list because the two drop-down-list in my page do not have parent/child relationship. Here's what I need to accomplish: 1.  First drop-down-list contains a list of Customer Code.  I can get this list using ObjectDataSource. 2.  After a Customer Code being chosen in the first field, can I pass that value to the second ObjectDataSource so it can use that value in a complex query to get the Customer Order?   Is there any other way to accomplish this? Thanks i...

Web resources about - How to take selected value of dropdownlist in web method using cascading dropdownlist - asp.net.ajax-discussion

Tag Synonyms - Stack Overflow
Q&A for professional and enthusiast programmers

Accidental entities - what about the UI?
This post is a follow-up to my previous blog post " Accidental entities - you don't need that identity ". In that post, we followed a consultant ...

Flash Builder Plug-in for SAP Netweaver Gateway - Adobe Labs
Search Navigation Labs Home Wiki Home Technologies Alchemy Blueprint Camera Profiles and DNG Profile Editor Cirrus ColdFusion 10 DNG Codec Fireworks ...

Air Astana - Join Now
Thank you for considering membership of Nomad Club – Kazakhstan’s first Frequent Flyer Program. You could soon be on your way to earning free ...

Languages -> C# Articles, Tutorials, Examples: ASP Alliance
.NET,ASP,ASP.NET,SQL,XML,HTML,ADO,ADO.NET,JavaScript,JScript,CSharp,VBScript and VB tutorials from AspAlliance.

Blog - Avisra
Avisra Web Development Home Blog Services Contact The Blog Latest Module Builder: How can we make it better? Sitefinity by Chris on July 2, 2013 ...

Online Booking Tool Support
This Online Booking Tool Support page might help you as you navigate through the process of booking travel through your OBT provided by CWT. ...

@Html and beyond
... ); } return string .Format( “{0}{1}” , me.Member.Name, id); } The Html building methods are quite simple. Building a dropdownlist for a ...

Top Ranked Articles
Top Ranked Articles - Free source code and tutorials for Software developers and Architects.; Updated: 23 Feb 2013

Unit Testing DateTime.Now Without Isolation
public virtual void SeedWithYearsSince(DropDownList list, int year){ for (int index = year; index

Resources last updated: 1/6/2016 10:51:26 AM