How do I set the selected value of child DropDownList control cascading

 Hello i use ajax with  CascadingDropDown for 2 dropdownlist, one parent and the second chield  for save this informatio in data base is ok, no problem, the question is when i load this information from database to my aspx, i can put the selected value in the dropdownlist parent was very good, but when y tried to put the select value to the chield i have the problem, the razon is that the chield dropdownlist is no load ... how i can load the chiel dropdown for clien side,,  any examples please

 for example in the proyect http://www.asp.net/learn/ajax-videos/video-278.aspx i want put one (input button) and using java script to said car = acure , Model = integra, color = blue ,,,, i supose this  

<script language="javascript" type="text/javascript">
<!--

function Button1_onclick() {
document.getElementById('ddlMakes').value=1;
document.getElementById('ddlModels').value=2;
document.getElementById('ddlColors').value=3;
}

// -->

</script>
but not working, how i can do, please

 


Juan Carlos Castillo
0
jccastillo
11/10/2008 3:53:54 PM
asp.net.ajax-discussion 13973 articles. 1 followers. Follow

9 Replies
1069 Views

Similar Articles

[PageSpeed] 48

Could we see your code?  What ServicePath and ServiceMethod are you using to populate the child?


I love to display the non-secure items...
Charlie Asbornsen
Dont forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
0
Charles
11/10/2008 4:06:13 PM

Please help my, thanks this is the code that i use for load the dropdowlist  when the user click for databind the chield dropdownlist

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:ScriptManager ID="ScriptManager1" runat="server"> 
      
      <Services>
          <asp:ServiceReference Path="WebS.asmx" />
        </Services>   
    </asp:ScriptManager>
    <table cellpadding="2" cellspacing="2">
            <tr>
                <td>
                    <table class="black" cellpadding="2" cellspacing="2">
                        <tr>
                            <td>Departamento <br /><br />
                                <asp:DropDownList ID="cboDepartamentoAfilia" runat="server" CssClass="black">
                                </asp:DropDownList>
                                <cc1:CascadingDropDown ID="cboDepartamentoAfilia_CascadingDropDown" 
                                        runat="server" 
                                        Enabled="True" 
                                        TargetControlID="cboDepartamentoAfilia"
                                        Category="Departamento" 
                                       PromptText="Seleccione Departamento" 
                                       LoadingText="Por Favor Espere..." 
                                       ServicePath="WebS.asmx" 
                                       ServiceMethod="GetDepartamento"
                                    >
                                </cc1:CascadingDropDown>
                                                             </td>
                            <td>Ciudad
                            <br /><br />
                                <asp:DropDownList ID="cboCiudadAfilia" runat="server" CssClass="black">
                                </asp:DropDownList>
                                <cc1:CascadingDropDown ID="cboCiudadAfilia_CascadingDropDown" 
                                    runat="server" 
                                    Enabled="True" 
                                    TargetControlID="cboCiudadAfilia" 
                                    ParentControlID="cboDepartamentoAfilia"
                                        Category="Ciudad" 
                                       PromptText="Seleccione Ciudad" 
                                       LoadingText="Por favor Espere..." 
                                       ServicePath="WebS.asmx" 
                                       ServiceMethod="GetCiudad_Dep"
                                    >
                                </cc1:CascadingDropDown>
                            </td>
the webservice is 
 <WebMethod()> _
Public Function GetDepartamento(ByVal knownCategoryValues As String, ByVal category As String) As CascadingDropDownNameValue()

With objConexion
.ConnectionString = objFunction.Cifrado(2, System.Configuration.ConfigurationManager.AppSettings("TARJETA_AZUL"))
dttTemp = .Query("select VDE_NID,VDE_CDESCRIPCION from dbo.TBL_RVENDEDOR_DEPARTAMENTO order by VDE_CDESCRIPCION asc", clsConnection.TipoDato.Table)
End With
Dim makeValues As New List(Of CascadingDropDownNameValue)()
For i = 0 To dttTemp.Rows.Count - 1
makeValues.Add(New CascadingDropDownNameValue(dttTemp.Rows(i).Item("VDE_CDESCRIPCION"), dttTemp.Rows(i).Item("VDE_NID")))
Next i

Return makeValues.ToArray()
End Function
<WebMethod()> _
Public Function GetCiudad_Dep(ByVal knownCategoryValues As String, ByVal category As String) As CascadingDropDownNameValue()
Dim VendorID As Integer
Dim kv As StringDictionary = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)
If Not kv.ContainsKey("Departamento") Or Not Int32.TryParse(kv("Departamento"), VendorID) Then
Throw New ArgumentException("No encontro ciudades")
End If
With objConexion
.ConnectionString = objFunction.Cifrado(2, System.Configuration.ConfigurationManager.AppSettings("TARJETA_AZUL"))
dttTemp = .Query("SELECT VCI_NID,VCI_CDESCRIPCION FROM dbo.TBL_RVENDEDOR_CIUDAD WHERE VDE_NID=" + CStr(VendorID), clsConnection.TipoDato.Table)
End With

Dim modelValues As New List(Of CascadingDropDownNameValue)()
For i = 0 To dttTemp.Rows.Count - 1 'carModelAdapter.GetModelsByCarId(makeId)
modelValues.Add(New CascadingDropDownNameValue(dttTemp.Rows(i).Item("VCI_CDESCRIPCION"), dttTemp.Rows(i).Item("VCI_NID")))

Next i
Return modelValues.ToArray()
End Function
this is the code when i tried to found (search in database) the html
function Button4_onclick() {
ret = WebS.Buscar_Cliente(document.getElementById('ctl00_ContentPlaceHolder1_txtNumeroDoc').value, OnCompleteBusqueda, OnTimeOut, OnError);
}
 function OnCompleteBusqueda(args)
{ args=args;
var vars = args.vars;

document.getElementById("ctl00_ContentPlaceHolder1_cboDepartamentoAfilia").value =vars[6]; //is ok
 document.getElementById("ctl00_ContentPlaceHolder1_cboCiudadAfilia").value=vars[7]; //this is the problem
the webservice  is  
 <WebMethod()> _
Public Function Buscar_Cliente(ByVal Documento As String) As ClienteObject
Dim co As New ClienteObject
With objConexion
.ConnectionString = objFunction.Cifrado(2, System.Configuration.ConfigurationManager.AppSettings("SUIM"))
.NameProcedure = "SPR_GET_CLIENTE"
.Parameters("@PI_NOPCION", 0) 'GET
.Parameters("@PI_NID", 0)
.Parameters("@PI_CDOCUMENTO", Documento)
dttTemp = .ExecuteProc(clsConnection.TipoDato.Table)
.DisposeProc()

co.vars(6) = CStr(dttTemp.Rows(0).Item("CLI_CCODDEP_AFILIA"))
co.vars(7) = CStr(dttTemp.Rows(0).Item("CLI_CCODCIU_AFILI"))
 this pasrt is ok
 
please help my 
 
 

 


Juan Carlos Castillo
0
jccastillo
11/10/2008 4:30:02 PM

Sorry, but I don't see an update panel there.  How do you do your postback?

Have you watched this video?

http://www.asp.net/learn/ajax-videos/video-77.aspx


I love to display the non-secure items...
Charlie Asbornsen
Dont forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
0
Charles
11/10/2008 4:41:06 PM

 ok thanks, maybe my english is not good, but my problem no is the cascading dropdownlist, when the user select one ddlis and the second ddlist is child, no is my problem because i work fine ans save this information in my database, and not use updatepanel, the problem is when i search (found) this information for database and show this in ddlist because i selected value the ddlist parent ok , but i need databind the child ddlist ofr make select value but only javascript clien side

 

o no pelase help my i need, finish one formulario of search thanks


Juan Carlos Castillo
0
jccastillo
11/10/2008 5:05:46 PM

AJAX extenders are designed to be used in update panels.  If you have some reason you can't use an update panel I recommend that you use two seperate regular ASP.Net DDLs.  When the parent DDL is updated, on the selected index updated event set the datasource for your child DDL to be a SQL query which uses the foreign key on the parent table to select the values from the child table.

For example, on the selected index changed event for the Parent, set a string: theSQL = "SELECT Value, Key from dbo." + ParentDDL.Value " Order By Value"

The following illustrates how to do something like that.  Modify it so that you set theSQL on the Parent DDL's selected index changed, the do a postback, and set the Child DataSource to theSQL and bind the child list in the child's PreRender event.

http://aspalliance.com/581


I love to display the non-secure items...
Charlie Asbornsen
Dont forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
0
Charles
11/10/2008 8:46:48 PM
Hi,

May be these threads about the WebService method of the CascadingDropDown are useful:

http://forums.asp.net/t/1274880.aspx
http://forums.asp.net/t/1319523.aspx
http://forums.asp.net/t/1334592.aspx
Use ASP.NET AJAX Cascading Drop Down Control to Access a Database

Have my suggestions helped?

Best regards,

Zhi-Qiang Ni


Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
Answer” if a marked post does not actually answer your question.
0
Zhi
11/14/2008 9:05:28 AM

 hey thanks but not is my solution, please help my, please

 i need for example in the proyect http://www.asp.net/learn/ajax-videos/video-278.aspx put one input button and using java script said car = acure , Model = integra, color = blue ,,,, i supose this

 
<script language="javascript" type="text/javascript">
<!--

function Button1_onclick() {
document.getElementById('ddlMakes').value=1;
document.getElementById('ddlModels').value=2;
document.getElementById('ddlColors').value=3;
}

// -->

</script>
but not working 
 

Juan Carlos Castillo
0
jccastillo
11/14/2008 7:34:58 PM

 go and see this code u will get the answer

http://forums.asp.net/t/1348373.aspx

0
anup1252000
11/16/2008 8:41:47 AM

hey,,,,, i research for many page of internet and this is not posibilite

thanks the only solution was using the update panel, and put this information the side server, and not using cascading dropdownlist

 

i am very sad,,


Juan Carlos Castillo
0
jccastillo
11/22/2008 2:35:25 PM
Reply:

Similar Artilces:

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 to set the cascading dropdownextendar value to the value of dropdownlist control
i have a cascading drop down extendar inside gridview , a dropdownlist control , a link button. i want to set the  value of dropdownextendar to the value of dropdown when i click the link button . <EditItemTemplate> <asp:DropDownList ID="ProvinceDDL" runat="server" /><act:CascadingDropDown ID="ProvinceCDD" runat="server" TargetControlID="ProvinceDDL" Category="Province" PromptText="- Please select a Province -" LoadingText="[Loading Province...]" ServicePath="LocactionService....

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"...

Setting selected value of DropDownList inside a repeater control
Hi everyone, I am binding a repeater control to a datatable. I bind 3 columns from the datatable to repeater columns. With an extra column being a DropDownList.I like on the ItemDataBound event to read a datavalue from the current record that is not displayed/bound to the repeater control (call it column4) and once I read that value I like to set the selected value of the dropDownList Control Many thanks in advance    Hey, Well what you should do is find your item every time you want to read from the drop down list. So what basically happens is : yo...

setting the selected value of a cascading drop down programatically not populating child lists
HiI am setting the selected value of a cascading drop down programmatically as shown:cddAccounts.TargetProperties(0).SelectedValue = Session("RequestAccountCode")This sets the selected value ok but it does not cause the child dropdowns that are dependent on this dropdown list to be populated. Please can you tell me what I'm doing wrong.thanks a lotandrea...

Setting a label value to a dropdownlist selected value
I am trying to set the value of a label to the selected value from a hidden dropdown list. This code is not working and the label value remians at its default. Any ideas? Thanks very much. Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Dim mylabel As Label Dim myddl As DropDownList If (DetailsView1.CurrentMode = DetailsViewMode.ReadOnly) Then mylabel = DetailsView1.FindControl("Label1") myddl = DetailsView1.FindControl("DropDownListViewOffice") mylabel.Text = myddl.SelectedValue.ToString End If I have now put this code in the Page_Load su...

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...

DropDownList Selected value to set gridview selected Index and page
I have a dropdownlist and a gridview that is bound to the same objectdatasource. In the gridview I am allowing paging.  When user select an item in the dropdownlist list I want to position the gridview selected value to that page and that record. Is there an easy way to do this. I tried this code Protected Sub GrdMyIssues_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GrdMyIssues.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then 'find the position data selected in the If e.Row.Cells(1).Text = Me.ViewSt...

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++)        {       &...

how can i Fill the controls on web page by selecting value from dropdownlist control.
  Hi,  Currentlly i am working on a web application where i require to fill the web form with the selected item in a text box. for example i have dropdown control named supplier_name, and i want to fill all the other controls values from database on the form when i select name from that supplier_name box,i.e , if i select name1, then related to that name, its code,address ,city should appear on related text boxes. I have done the same in windows application with c# , but the problem with web application(asp.net) is that, when i select Supplier _ it...

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 (...

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(known...

Cascading Dropdownlist Extender Control, SQL Server 2000, AJAX Calendar Extender Control
1. Cascading Dropdownlist Extender Control:Hi Guys, I started implementing AJAX Controls on a in-house project in my company which requires me to use the AJAX Cascading Dropdown extender control. The issue I'm have here is, my main datasource is from sql server 2000. How do I query my datasource as well as linking the web services back to the main aspx file? I pray that someone will have the answer soon.2. AJAX Calendar Extender Control:Another issue I'm facing is that on a same form page, when I have 1 or more dropdownlists that are cascading, the autopostback effect causes my calender to f...

DropdownList and Setting Selected Value
I have built a simple web page using VB .NET 2005, (and Visual Studio 2005) with a dropdownlist. The datasource for the dropdownlist is a SqlDataSource which I dragged on to form in design view.  I am pulling a list of about ten records from a sql server 2000 database table.  When I run the page, it works fine (dropdownlist shows the 10 or so items from the database when I click the dropdown button).  Now, what I want is to set the value in that drop down box in VB code so that when the web page displays, I can control which of those 10 or so items is selected in the dro...

Web resources about - How do I set the selected value of child DropDownList control cascading - 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/8/2016 6:33:41 AM