Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>in your page, write this js method, it takes a parent and a child dropdown and it will fill the child dropdown asynchronously based on the parent dropdown's selected value:</p> <pre><code> function LoadDataHandle(cmbParent,cmbChild,Type) { var cmb = document.getElementById(cmbParent); var mydate = new Date() mydate.setDate(mydate.getDate()) $.get("GetItems.aspx?ID=" + cmb.value + "&amp;Type=" + Type + "&amp;x=" + mydate.getMilliseconds(), function(data) { LoadData(data, cmbChild); }); } function LoadData(strData, cmbChild) { var cmb = document.getElementById(cmbChild); cmb.options.length = 0; var choose = document.createElement('option'); choose.text = "--- اختر ---"; choose.value = -1; cmb.add(choose); if (strData.length &gt; 0) { var data = strData.split('$'); var i = 0; for (i = 0; i &lt; data.length - 1; i++) { var data1 = data[i].split('#'); var item = document.createElement('option'); item.value = data1[0]; item.text = data1[1]; cmb.add(item); } } } </code></pre> <p>note that use of jqyery's $get method passing in the aspx page having the parentid in the query string.</p> <p>now in your page_load event of the aspx page containing the dropdowns</p> <pre><code> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load cmdParent.Attributes.Add("onchange", "LoadDataHandle('" &amp; cmdParent.ClientID &amp; "','" &amp; cmdChild.ClientID &amp; "');") End Sub </code></pre> <p>we are almost done, note that in the GetItems.aspx age you will need to write out the items that should be filled in the child dropdown items as a single long string where each item is separated by a '#'. here is a sample of doing this :</p> <pre><code> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim ID As Integer = Request.QueryString("ID") Response.Write(GetDepartment(ID)) End Sub Private Function GetDepartment(ByVal ID As String) As String Dim dt As DataTable = 'get from db If dt IsNot Nothing AndAlso dt.Rows.Count &gt; 0 Then Dim sb As New StringBuilder(dt.Rows.Count * 20) For Each row As DataRow In dt.Rows sb.AppendFormat("{0}#{1}$", row(0), row(1)) Next Return sb.ToString End If Return "" End Function </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload