By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,995 Members | 1,192 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,995 IT Pros & Developers. It's quick & easy.

problem is displaying values in html select control

100+
P: 375
Hi,

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
  1. <SELECT class="TextBoxLabel" id="ddlMap" style="WIDTH: 128px;" tabIndex="1" onchange="fnChangeMap();"
  2.  
  3. name="ddlMap" runat="server">
  4.  
  5.  
  6. </SELECT>
  7.  
  8.  
  9.  
  10. function fnChangeMap()
  11.  
  12.  
  13. if(document.frmLiveTrack.ddlMap.value != 0){
  14.  
  15. var vMap = document.frmLiveTrack.ddlMap.value;
  16.  
  17. var vMapValues = vMap.split(",");
  18.  
  19. for(i=0 ; i < vMapValues.length ; i=i+5)
  20.  
  21. {
  22.  
  23. document.mapping.country.value = vMapValues[i];
  24.  
  25. document.frmLiveTrack.country.value = vMapValues[i];
  26.  
  27. document.frmLiveTrack.country1.value = vMapValues[i];
  28.  
  29. document.mapping.Lat.value = vMapValues[i+1];
  30.  
  31. document.mapping.Lon.value = vMapValues[i+2];
  32.  
  33. document.mapping.scale.value = vMapValues[i+3];
  34.  
  35. document.frmLiveTrack.DefaultURL.value = vMapValues[i+4];
  36.  
  37. }
  38.  
  39. //alert(document.frmLiveTrack.DefaultURL.value);
  40.  
  41. document.mapping.target = "MainFrame";
  42.  
  43. document.mapping.method = "get";
  44.  
  45. document.mapping.action = document.frmLiveTrack.DefaultURL.value; 
  46.  
  47. document.mapping.submit(); 
  48.  
  49. }
  50.  
  51. else{
  52.  
  53. alert("Select a Map");
  54.  
  55. }
  56.  
  57. }
  58.  
  59.  
  60.  
  61. Further i have a function called as load map which is called in page load event
  62.  
  63. private void LoadMap(string strUserId, int iUserType)
  64.  
  65. {
  66.  
  67. this.loadmapval = "Dhanus";
  68.  
  69. string text1 = "";
  70.  
  71. DataSet set1 = new DataSet();
  72.  
  73. ConnectionCls cls1 = new ConnectionCls();
  74.  
  75. text1 = TrackQuery.getMapQry(strUserId, iUserType);
  76.  
  77. set1 = cls1.dsGetValues(text1);
  78.  
  79. string text2 = base.Request.Params["country"];
  80.  
  81. if (iUserType == 1)
  82.  
  83. {
  84.  
  85. this.ddlMap.Visible = true;
  86.  
  87. this.lblCountry.Visible = false;
  88.  
  89. if (set1.Tables[0].Rows.Count > 0)
  90.  
  91. {
  92.  
  93. for (int num1 = 0; num1 < set1.Tables[0].Rows.Count; num1++)
  94.  
  95. {
  96.  
  97. DataRow row1 = set1.Tables[0].Rows[num1];
  98.  
  99. string text3 = Convert.ToString(row1["MAPNAME"]);
  100.  
  101. text3 = text3 + "," + Convert.ToString(row1["MAPLAT"]);
  102.  
  103. text3 = text3 + "," + Convert.ToString(row1["MAPLONG"]);
  104.  
  105. text3 = text3 + "," + Convert.ToString(row1["MAPSCALE"]);
  106.  
  107. string text7 = text3;
  108.  
  109. text3 = text7 + "," + Convert.ToString(row1["MAP_URL"]) + "/" + Convert.ToString(row1["ENGINE_DEFAULT_URL"]);
  110.  
  111. if (text2.Equals(Convert.ToString(row1["MAPNAME"])))
  112.  
  113. {
  114.  
  115. this.strMapDetail = text3;
  116.  
  117. }
  118.  
  119. this.ddlMap.Items.Add(new ListItem(row1["MAPNAME"].ToString(), text3));
  120.  
  121. }
  122.  
  123. }
  124.  
  125. }
  126.  
  127. else if (iUserType == 2)
  128.  
  129. {
  130.  
  131. this.ddlMap.Visible = true;
  132.  
  133. this.lblCountry.Visible = false;
  134.  
  135. if (set1.Tables[0].Rows.Count > 0)
  136.  
  137. {
  138.  
  139. for (int num2 = 0; num2 < set1.Tables[0].Rows.Count; num2++)
  140.  
  141. {
  142.  
  143. DataRow row2 = set1.Tables[0].Rows[num2];
  144.  
  145. string text4 = Convert.ToString(row2["MAPNAME"]);
  146.  
  147. text4 = text4 + "," + Convert.ToString(row2["MAPLAT"]);
  148.  
  149. text4 = text4 + "," + Convert.ToString(row2["MAPLONG"]);
  150.  
  151. text4 = text4 + "," + Convert.ToString(row2["MAPSCALE"]);
  152.  
  153. string text8 = text4;
  154.  
  155. text4 = text8 + "," + Convert.ToString(row2["MAP_URL"]) + "/" + Convert.ToString(row2["ENGINE_DEFAULT_URL"]);
  156.  
  157. if (text2.ToUpper().Equals(Convert.ToString(row2["MAPNAME"]).ToUpper()))
  158.  
  159. {
  160.  
  161. this.strMapDetail = text4;
  162.  
  163. }
  164.  
  165. this.ddlMap.Items.Add(new ListItem(row2["MAPNAME"].ToString(), text4));
  166.  
  167. }
  168.  
  169. }
  170.  
  171. }
  172.  
  173. else
  174.  
  175. {
  176.  
  177. this.ddlMap.Visible = true;
  178.  
  179. this.lblCountry.Visible = false;
  180.  
  181. if (set1.Tables[0].Rows.Count > 0)
  182.  
  183. {
  184.  
  185.  
  186. if (set1.Tables[0].Rows.Count > 0)
  187.  
  188. {
  189.  
  190. for (int num3 = 0; num3 < set1.Tables[0].Rows.Count; num3++)
  191.  
  192. {
  193.  
  194. DataRow row3 = set1.Tables[0].Rows[num3];
  195.  
  196. string text5 = Convert.ToString(row3["MAPNAME"]);
  197.  
  198. text5 = text5 + "," + Convert.ToString(row3["MAPLAT"]);
  199.  
  200. text5 = text5 + "," + Convert.ToString(row3["MAPLONG"]);
  201.  
  202. text5 = text5 + "," + Convert.ToString(row3["MAPSCALE"]);
  203.  
  204. string text9 = text5;
  205.  
  206. text5 = text9 + "," + Convert.ToString(row3["MAP_URL"]) + "/" + Convert.ToString(row3["ENGINE_DEFAULT_URL"]);
  207.  
  208. if (text2.Equals(Convert.ToString(row3["MAPNAME"])))
  209.  
  210. {
  211.  
  212. this.strMapDetail = text5;
  213.  
  214. }
  215.  
  216. this.ddlMap.Items.Add(new ListItem(row3["MAPNAME"].ToString(), text5));
  217.  
  218. }
  219.  
  220. }
  221.  
  222. }
  223.  
  224. else
  225.  
  226. {
  227.  
  228.  
  229. StringBuilder builder1 = new StringBuilder();
  230.  
  231. builder1.Append("SELECT MAPNAME FROM MAP_SUPERUSER ");
  232.  
  233. builder1.Append(" WHERE ");
  234.  
  235. builder1.Append(" SUPERUSERID = (SELECT SUPERUSERID ");
  236.  
  237. builder1.Append(" FROM USERS WHERE USERID='" + strUserId + "')");
  238.  
  239. builder1.Append(" AND DEFAULT_MAP ='1'");
  240.  
  241. string text6 = (string)cls1.ExecuteScalar(builder1.ToString());
  242.  
  243. this.lblCountry.Text = text6;
  244.  
  245. this.strCountry = text6;
  246.  
  247. }
  248.  
  249. this.ViewState["COUNTRY"] = this.strCountry;
  250.  
  251. }
  252.  
  253. }
Now to my problem, when I choose any values from the dropdownlist1, the values in the html select control called ddlmap gets vanished.

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
Mar 12 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.