I have two controls one html select control and one asp.net dropdownlist control.
In html select control i have three maps loaded. It is loaded in the following manner.
Expand|Select|Wrap|Line Numbers
- <SELECT class="TextBoxLabel" id="ddlMap" style="WIDTH: 128px;" tabIndex="1" onchange="fnChangeMap();"
- name="ddlMap" runat="server">
- </SELECT>
- function fnChangeMap()
- {
- if(document.frmLiveTrack.ddlMap.value != 0){
- var vMap = document.frmLiveTrack.ddlMap.value;
- var vMapValues = vMap.split(",");
- for(i=0 ; i < vMapValues.length ; i=i+5)
- {
- document.mapping.country.value = vMapValues[i];
- document.frmLiveTrack.country.value = vMapValues[i];
- document.frmLiveTrack.country1.value = vMapValues[i];
- document.mapping.Lat.value = vMapValues[i+1];
- document.mapping.Lon.value = vMapValues[i+2];
- document.mapping.scale.value = vMapValues[i+3];
- document.frmLiveTrack.DefaultURL.value = vMapValues[i+4];
- }
- //alert(document.frmLiveTrack.DefaultURL.value);
- document.mapping.target = "MainFrame";
- document.mapping.method = "get";
- document.mapping.action = document.frmLiveTrack.DefaultURL.value;
- document.mapping.submit();
- }
- else{
- alert("Select a Map");
- }
- }
- Further i have a function called as load map which is called in page load event
- private void LoadMap(string strUserId, int iUserType)
- {
- this.loadmapval = "Dhanus";
- string text1 = "";
- DataSet set1 = new DataSet();
- ConnectionCls cls1 = new ConnectionCls();
- text1 = TrackQuery.getMapQry(strUserId, iUserType);
- set1 = cls1.dsGetValues(text1);
- string text2 = base.Request.Params["country"];
- if (iUserType == 1)
- {
- this.ddlMap.Visible = true;
- this.lblCountry.Visible = false;
- if (set1.Tables[0].Rows.Count > 0)
- {
- for (int num1 = 0; num1 < set1.Tables[0].Rows.Count; num1++)
- {
- DataRow row1 = set1.Tables[0].Rows[num1];
- string text3 = Convert.ToString(row1["MAPNAME"]);
- text3 = text3 + "," + Convert.ToString(row1["MAPLAT"]);
- text3 = text3 + "," + Convert.ToString(row1["MAPLONG"]);
- text3 = text3 + "," + Convert.ToString(row1["MAPSCALE"]);
- string text7 = text3;
- text3 = text7 + "," + Convert.ToString(row1["MAP_URL"]) + "/" + Convert.ToString(row1["ENGINE_DEFAULT_URL"]);
- if (text2.Equals(Convert.ToString(row1["MAPNAME"])))
- {
- this.strMapDetail = text3;
- }
- this.ddlMap.Items.Add(new ListItem(row1["MAPNAME"].ToString(), text3));
- }
- }
- }
- else if (iUserType == 2)
- {
- this.ddlMap.Visible = true;
- this.lblCountry.Visible = false;
- if (set1.Tables[0].Rows.Count > 0)
- {
- for (int num2 = 0; num2 < set1.Tables[0].Rows.Count; num2++)
- {
- DataRow row2 = set1.Tables[0].Rows[num2];
- string text4 = Convert.ToString(row2["MAPNAME"]);
- text4 = text4 + "," + Convert.ToString(row2["MAPLAT"]);
- text4 = text4 + "," + Convert.ToString(row2["MAPLONG"]);
- text4 = text4 + "," + Convert.ToString(row2["MAPSCALE"]);
- string text8 = text4;
- text4 = text8 + "," + Convert.ToString(row2["MAP_URL"]) + "/" + Convert.ToString(row2["ENGINE_DEFAULT_URL"]);
- if (text2.ToUpper().Equals(Convert.ToString(row2["MAPNAME"]).ToUpper()))
- {
- this.strMapDetail = text4;
- }
- this.ddlMap.Items.Add(new ListItem(row2["MAPNAME"].ToString(), text4));
- }
- }
- }
- else
- {
- this.ddlMap.Visible = true;
- this.lblCountry.Visible = false;
- if (set1.Tables[0].Rows.Count > 0)
- {
- if (set1.Tables[0].Rows.Count > 0)
- {
- for (int num3 = 0; num3 < set1.Tables[0].Rows.Count; num3++)
- {
- DataRow row3 = set1.Tables[0].Rows[num3];
- string text5 = Convert.ToString(row3["MAPNAME"]);
- text5 = text5 + "," + Convert.ToString(row3["MAPLAT"]);
- text5 = text5 + "," + Convert.ToString(row3["MAPLONG"]);
- text5 = text5 + "," + Convert.ToString(row3["MAPSCALE"]);
- string text9 = text5;
- text5 = text9 + "," + Convert.ToString(row3["MAP_URL"]) + "/" + Convert.ToString(row3["ENGINE_DEFAULT_URL"]);
- if (text2.Equals(Convert.ToString(row3["MAPNAME"])))
- {
- this.strMapDetail = text5;
- }
- this.ddlMap.Items.Add(new ListItem(row3["MAPNAME"].ToString(), text5));
- }
- }
- }
- else
- {
- StringBuilder builder1 = new StringBuilder();
- builder1.Append("SELECT MAPNAME FROM MAP_SUPERUSER ");
- builder1.Append(" WHERE ");
- builder1.Append(" SUPERUSERID = (SELECT SUPERUSERID ");
- builder1.Append(" FROM USERS WHERE USERID='" + strUserId + "')");
- builder1.Append(" AND DEFAULT_MAP ='1'");
- string text6 = (string)cls1.ExecuteScalar(builder1.ToString());
- this.lblCountry.Text = text6;
- this.strCountry = text6;
- }
- this.ViewState["COUNTRY"] = this.strCountry;
- }
- }
eg. if there are three values 1,2,3 by default the value 1 is displayed on the select control and the values 2,3 are in the dropdown area whereas when i choose the value from dropdownlist(server control) nothing is displayed. The select control is empty and all the values 1,2,3 are in dropdown area.
i tried giving ddlmap.SelectedIndex = 1;
but to no avail.
Kindly help please
Regards
cmrhema