Click here to Skip to main content
15,908,264 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi to all.

i am binding dropdownlist in javascript through ajax pro method in code behind, now i want it's selected value in code behind.

Problem is that value is become null when i click save button in code behind. here is the code
C#
  [AjaxPro.AjaxMethod]
      public DataSet  GetServerTime(DataSet ds)
      {
          con.Open();
          SqlDataAdapter adp = new SqlDataAdapter("select M_code,M_name from ICA", con);
          ds = new DataSet();
          adp.Fill(ds);
          return ds;

      }

 // now i am binding this in javascript :

   function getServerTime(res) {

       res = _Default.GetServerTime();
       var list =document.getElementById('<%= Drpscore.ClientID%>');

       for(var i=0; i < res.value.Tables[0].Rows.length; i++)
       {
         opt = new Option(res.value.Tables[0].Rows[i].M_name,res.value.Tables[0].Rows[i].M_code);
         list.options.add(opt);
       }

      }

  so now i have a button that i use to insert. the problem is that dropdown selected value not appear.

   protected void Button1_Click(object sender, EventArgs e)
      {
          string p = "";
          string t = Drpscore.selectedvalue;



      }

//  here t is coming null
Posted
Updated 10-Sep-12 19:00pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900