- //INDEX
- <script src="~/scripts/jquery-1.10.2.min.js">script>
- <script src="~/scripts/bootstrap.min.js">script>
- <link href="~/Content/bootstrap.min.css" rel="stylesheet" />
- <div class="container" style="margin-top :4%">
- <a href="#" class="btn btn-info" onclick="AddnewStudent(0)"> Add New Studenta>
- <table class="table table-striped">
- <thead>
- <tr>
- <th>Student Nameth>
- <th>Email IDth>
- <th>Departmentth>
- <th>Editth>
- <th>Deleteth>
- tr>
- thead>
- <tbody id="SetStudentList">
- <tr id="LoadingStatus" style="color:red">tr>
- tbody>
- table>
- div>
My student list not comming
- //javascript
- $('#LoadingStatus').html("Loading....")
- //$.get("@Url.Action("GetStudentList","Home")", null, DataBind);
- $.ajax({
- type: 'Get',
- url: "@Url.Action("GetStudentList", "Home")",
- datatype: 'json',
- success: function DataBind(StudentList) {
- var SetData = $('#SetStudentList');
- for (var i = 0; i < StudentList.length; i++) {
- var Data = "
+ StudentList[i].studentID + "'>" + ";- "
" + StudentList[i].studentName + " " +- "
" + StudentList[i].email + " " +- "
" + StudentList[i].DepartmentName + " " +- "
" + " + StudentList[i].studentID + ")' >" + " " +- "
" + " + StudentList[i].studentID + ")'>" + " " +- "
- "
- SetData.append(Data);
- // $("#LoadingStatus").html(" ");
- }
- },
- error: function (DataBind) {
- alert(DataBind.message);
- }
- })
- public List
GetStudData() - {
- connection();
- List
students = new List (); - string Sqry = "select st.StudentID,st.StudentName,st.Email, st.isDelete,st.Department_ID,dt.Department_Name from tbl_Student st "
- + "inner join tbl_Department dt on dt.Department_ID = st.Department_ID";
- SqlCommand cmd = new SqlCommand(Sqry,con);
- cmd.CommandType = CommandType.Text;
- SqlDataAdapter sdr = new SqlDataAdapter(cmd);
- DataTable dt = new DataTable();
- con.Open();
- sdr.Fill(dt);
- con.Close();
- foreach(DataRow dr in dt.Rows)
- {
- students.Add(
- new StudentDetails
- {
- studentID = Convert.ToInt32(dr["StudentID"]),
- studentName =Convert.ToString(dr["StudentName"]),
- email = Convert.ToString(dr["Email"]),
- IsDeleted = Convert.ToBoolean(dr["isDelete"]),
- DepartmentId = Convert.ToInt32(dr["Department_ID"]),
- DepartmentName = Convert.ToString(dr["Department_Name"]),
- });
- }
- return students;
- }
- public JsonResult GetStudentList()
- {
- StudentDetails stud = new StudentDetails();
- var students = stud.GetStudData();
- return Json(new { data = students }, JsonRequestBehavior.AllowGet);
- }
Asma KhalidPosted Aug 17, 2018, 9:28 AM
Vincent Maverick DuranoPosted Aug 17, 2018, 8:53 AM