<script type="text/javascript" language="javascript"> $(document).ready(function() { $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "QuotaMaster.aspx/BindDatatoDropdown", data: "{}", dataType: "json", success: function(data) { $.each(data.d, function(key, value) { $('#<%=ddlmode.ClientID%>').append($("<option></option>").val(value.mode_id).html(value.planmode)); }); }, error: function(result) { alert(result); } }); }); </script>
[WebMethod] protected static BindModeDetails[] BindDatatoDropdown() { try { DataTable dt = new DataTable(); List<BindModeDetails> bindMode = new List<BindModeDetails>(); using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constring"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand("select mode_id ,planmode From tbl_planmode",con)) { if (con.State == ConnectionState.Closed) { con.Open(); } SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); foreach (DataRow drRow in dt.Rows) { BindModeDetails mode = new BindModeDetails(); mode.mode_id = int.Parse(drRow["mode_id"].ToString()); mode.Planmode = drRow["planmode"].ToString(); bindMode.Add(mode); } if (con.State == ConnectionState.Open) { con.Close(); } } } return bindMode.ToArray(); } catch (Exception ex) { throw ex; } } public class BindModeDetails { public int mode_id { get; set; } public string Planmode { get; set; } }
<system.webServer> <validation validateIntegratedModeConfiguration="false" /> </system.webServer>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)