TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Guest User
Tech Writer
189
24.8k
My student list not comming
Aug 17 2018 7:43 AM
//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 Student
</
a
>
<
table
class
=
"table table-striped"
>
<
thead
>
<
tr
>
<
th
>
Student Name
</
th
>
<
th
>
Email ID
</
th
>
<
th
>
Department
</
th
>
<
th
>
Edit
</
th
>
<
th
>
Delete
</
th
>
</
tr
>
</
thead
>
<
tbody
id
=
"SetStudentList"
>
<
tr
id
=
"LoadingStatus"
style
=
"color:red"
>
</
tr
>
</
tbody
>
</
table
>
</
div
>
//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 =
"<tr class='row_"
+ StudentList[i].studentID +
"'>"
+
"<td>"
+ StudentList[i].studentName +
"</td>"
+
"<td>"
+ StudentList[i].email +
"</td>"
+
"<td>"
+ StudentList[i].DepartmentName +
"</td>"
+
"<td>"
+
"<a href='#' class='btn btn-warning' onclick='EditStudentRecord("
+ StudentList[i].studentID +
")' ><span class='glyphicon glyphicon-edit'></span></a>"
+
"</td>"
+
"<td>"
+
"<a href='#' class='btn btn-danger' onclick='DeleteStudentRecord("
+ StudentList[i].studentID +
")'><span class='glyphicon glyphicon-trash'></span></a>"
+
"</td>"
+
"</tr>"
;
SetData.append(Data);
// $("#LoadingStatus").html(" ");
}
},
error:
function
(DataBind) {
alert(DataBind.message);
}
})
public
List<StudentDetails> GetStudData()
{
connection();
List<StudentDetails> students =
new
List<StudentDetails>();
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);
}
Reply
Answers (
2
)
Unable to make the session state request to the session stat
Dynamic Textbox