Тёмный

Asp.Net and Jquery AJAX to Bind DropDownList dynamically from Sql server database 

Vetrivel D
Подписаться 41 тыс.
Просмотров 63 тыс.
50% 1

In this Video I am going to explain with example How to fill/populate asp.net dropdown list dynamically from sql server database by calling C# server side code from client side using jquery AJAX and json.

Опубликовано:

 

22 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 26   
@tjkingchan8564
@tjkingchan8564 9 лет назад
Thank you very much. This is my best Solution for me. after I find out all the world.
@VetrivelD
@VetrivelD 9 лет назад
+ทนงศักดิ์ จันทะสิงห์ Thank You.. Please Post your Question?
@sriramr1981
@sriramr1981 4 года назад
Semma ji... Very useful. Thanks a lot
@howard123666
@howard123666 9 лет назад
Thank you for your Video! It's very useful to me!
@graysonelliott5649
@graysonelliott5649 3 года назад
i know I'm kinda randomly asking but do anyone know a good website to stream new tv shows online?
@VetrivelD
@VetrivelD 9 лет назад
Step: 1 Step: 2 Populate DropDownList using jQuery AJAX Select Student: Step: 3 using System.Configuration; using System.Data; using System.Data.SqlClient; using System.Web.Services; Step: 4 public class Student { public string StuId { get; set; } public string StuName { get; set; } } [WebMethod] public static List PopulateDropDownList() { DataTable dt = new DataTable(); List objDept = new List(); using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conStr"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand("SELECT ID,Stu_Name FROM Student", con)) { con.Open(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { objDept.Add(new Student { StuId = dt.Rows[i]["ID"].ToString(), StuName = dt.Rows[i]["Stu_Name"].ToString() }); } } return objDept; } } } Step: 5 $(document).ready(function () { $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", //url is the path of our web method (Page name/function name) url: "JQueryBindDropDown.aspx/PopulateDropDownList", data: "{}", dataType: "json", //called on jquery ajax call success success: function (result) { $('#ddlStudent').empty(); $('#ddlStudent').append("--Select--"); $.each(result.d, function (key, value) { $("#ddlStudent").append($("").val(value.StuId).html(value.StuName)); }); }, //called on jquery ajax call failure error: function ajaxError(result) { alert(result.status + ' : ' + result.statusText); } }); });
@savithirir7282
@savithirir7282 5 лет назад
What result
@RaulJordan23
@RaulJordan23 7 лет назад
Thank you very much!. it was very usefull!!!!
@VetrivelD
@VetrivelD 6 лет назад
Thanks for your valuable feedback. Refer our channel in your friend circle.
@SaiRam1990_
@SaiRam1990_ 9 месяцев назад
Hi i saw your video. Very helpful. But i need the same for gridview . Pls help me
@alexanderrodrigues9003
@alexanderrodrigues9003 5 лет назад
Thank you!!!
@DavidG-qm5vf
@DavidG-qm5vf 9 лет назад
Nice video! Thanks for your video!
@VetrivelD
@VetrivelD 9 лет назад
+Jose David Thank You.. Please Post your Question?
@ikramlim
@ikramlim 7 лет назад
Thank you very much. but I have a question if I want to bind the data from service how I can change it?? Example public void GetAgencyNames() { var listOfAgencyNames = UserProfileService.GetAgencyNames(agencyNAMEVO); DropDownAgencyName.DataSource = listOfAgencyNames; DropDownAgencyName.DataValueField = "AgencyName"; DropDownAgencyName.DataTextField = "AgencyName"; DropDownAgencyName.DataBind(); DropDownAgencyName.Items.Insert(0, new ListItem("Please select a value", "")); } Please help.. Thanks
@jasminem8457
@jasminem8457 3 года назад
I tried this one before watching this,the same way I bind ddl with Ajax...and work out for me, but after that in save button I have to save the ddl value to the db table, but I get the selected value as empty...I stuck with this today...🤔
@humbertoporras4488
@humbertoporras4488 6 лет назад
Thanks
@priyankatripathi562
@priyankatripathi562 8 лет назад
Can you please provide the script of the code because I am unable to get the code and I have having two column in a table States and country so is it necessary to have ID column also.I want to populate the States only and on the basis of selection of State in Dropdownlist I need to pupulate the Cities name in the checkboxlist and that checkboxlist should be bind from database.Can you please help me on this.Thanks
@priyankatripathi562
@priyankatripathi562 8 лет назад
Hi Sir,Can you help on the same on the problem I have mentioned.
@kibelo2267
@kibelo2267 5 лет назад
Nice!!!
@pshah2952
@pshah2952 9 лет назад
Good clear steps but very slow video
@duttpankaj5477
@duttpankaj5477 7 лет назад
hi sir can u provide code like if i am select picture of state there city picture is open.if i select city picture there area picture will display.the query is like state?cityid=1.please sir provide this code.
@diegodiaz6815
@diegodiaz6815 7 лет назад
step 1 step2 step 3 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Configuration; using System.Data; using System.Data.SqlClient; using System.Web.Services; public partial class AjaxDataBlindDropDown : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } public class cierre { public string idCierreInd { get; set; } public string Cierre { get; set; } } [WebMethod] public static List ddl() { DataTable dt = new DataTable(); String CS = ConfigurationManager.ConnectionStrings["t3Procesos"].ConnectionString; List objDept = new List(); using (SqlConnection con = new SqlConnection(CS)) { using (SqlCommand cmd = new SqlCommand("SELECT TOP 100 idCierreInd,Cierre from [t3Procesos].dbo.m_cierreIndividual", con)) { con.Open(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { objDept.Add(new lcierre { idCierreInd = dt.Rows[i]["idCierreInd"].ToString(), Cierre = dt.Rows[i]["Cierre"].ToString() }); } } return objDept; } } } } step 4 $(document).ready(function(){ $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "AjaxDataBlindDropDown.aspx/ddl", data: "{}", dataType: "json", success: function (result) { $('#DropDownList1').empty(); $('#DropDownList1').append("--Select--"); $.each(result.d, function (key,value) { $('#DropDownList1').append($("").val(value.idCierreInd).html(value.Cierre)); }); }, failure: function ajaxError(result) { alert(result.status +':'+ result.statusText); } }); });
@kishanwebsolution8690
@kishanwebsolution8690 7 лет назад
plz sir solve my problem product searching use autocomplete
@shwetabhat6815
@shwetabhat6815 2 года назад
Can I get code please
Далее
Calling asp net web services using jquery ajax
15:44
Просмотров 97 тыс.
Как не носить с собой вещи
00:31
Calling aspx page method using jquery
11:12
Просмотров 83 тыс.
Ajax Controls in Asp Net using C#
16:18
Просмотров 5 тыс.
Solving one of PostgreSQL's biggest weaknesses.
17:12
Просмотров 205 тыс.
Как не носить с собой вещи
00:31