title: Getting the ID in of an ASP drop down list from client side
body: <p>What I'm trying to do is get one of my drop down list to change its contents whenever the selected item in another one cahnges.  I have this code in my aspx file:</p>
  
  <pre><code>function ModifyDDLItems(id1, id2) 
  {
      var ddlcontrolShown = document.getElementById(id1);
      var ddlcontrolHidden = document.getElementById(id2);
  
      if (ddlcontrolShown.options[ddlcontrolShown.selectedIndex].value == "DD1") 
      {
          //Get number of items of hidden ddl
          var length = ddlcontrolHidden.options.length;
  
          //Clear items of shown ddl
          ddlcontrolShown.options.length = 0;
  
          //Add itmems of hidden ddl to shown ddl
          for (i = 0; i &lt; length; i++) 
          {
              ddlcontrolShown.options.add
              var newoption = document.createElement("option")
              newoption.text = ddlcontrolHidden.options[i].text;
              newoption.value = ddlcontrolHidden.options[i].text.value;
          }         
      }   
  }
  </code></pre>
  
  <p>Now, i give it the front end ID's thru this:</p>
  
  <pre><code>protected void SetDD1ConfItems(GridViewRow gvRow, DataSet BaseConfItems)
  {
      DataView dvConfType = new DataView(BaseConfItems.Tables[0]);
      DataSet dsTemp = BaseConfItems.Clone();
  
      DropDownList ddlConfType2 = (DropDownList)form1.FindControl("ddlConfType2");
      DropDownList ddlBA = (DropDownList)gvRow.FindControl("ddlBA");
      DropDownList ddlConfType = (DropDownList)gvRow.FindControl("ddlConfType");
  
      dvConfType.RowFilter = "ref_code = 'FAX' or ref_code = 'EEX' or ref_code = 'EPD'";
  
      dsTemp.Tables.Clear();
      dsTemp.Tables.Add(dvConfType.ToTable());
  
      ddlConfType2.DataSource = dsTemp;
      ddlConfType2.DataBind();
      //ddlBA.Attributes["onchange"] = "function GetDDLD(" + ddlConfType.ClientID + ", " + ddlConfType2.ClientID + ") {ModifyDDLItems(id1, id2);}";
      ddlBA.Attributes.Add("onchange", "ModifyDDLItems('" + ddlConfType.ClientID + "', '" + ddlConfType2.ClientID + "')");
  }
  </code></pre>
  
  <p>When I run it, VS keeps on telling me that id1 and id2 are both null, it seems the id's aren't passed to the client properly.</p>