Bind Any Table which comes from code behind stored procedure calling....Like this simply make a method which is webmethod into code behind and call it on client side.The Total code is below I am writing here.
//--------------------Bind Elective Papers on Change Of Specialization------------------
function ShowElectivePapers() {
var dCID = document.getElementById('<%= ddlCourse.ClientID%>');
var CourseID = dCID.options[dCID.selectedIndex].value;
var dSID = document.getElementById('<%= ddlSemester.ClientID%>');
var SemID = dSID.options[dSID.selectedIndex].value;
var dSpec = document.getElementById('<%= ddlSpecialization.ClientID%>');
var SpecID = dSpec.options[dSpec.selectedIndex].value;
if (SpecID != 0) {
BindElectivePapers(CourseID, SemID, SpecID);
}
}
function BindElectivePapers(CCode, SemId, Spec) {
$.ajax({
type: "POST",
url: "StudentRegistration.aspx/BindElectivePapers",
contentType: "application/json; charset=utf-8",
data: "{'CCode': '" + CCode + "','SemId': '" + SemId + "','Spec': '" + Spec + "'}",
dataType: "json",
async: false,
success: AjaxSucceeded,
error: AjaxFailed
});
function AjaxSucceeded(result) {
DisplayChildren(result);
}
function AjaxFailed(result) {
alert('no success');
}
function DisplayChildren(result) {
var dtEpaper = eval(result.d);
if (dtEpaper != null && typeof (dtEpaper) == "object") {
document.getElementById('<%= dvElectivePapers.ClientID%>').style.display = '';
var s = new Array();
s[s.length] = "
Elective Papers
"s[s.length] = "
s[s.length] = "
"
s[s.length] = "
";
s[s.length] = "
";
s[s.length] = "
";
s[s.length] = "
";
s[s.length] = "
";
for (var i = 0; i < dtEpaper.Table.length; i++) {
s[s.length] = "
";
s[s.length] = "
";
s[s.length] = "
";
s[s.length] = "
";
}
s[s.length] = "
";
s[s.length] = "
";s[s.length] = "
";
s[s.length] = "
";
s[s.length] = "
";
s[s.length] = "
";
s[s.length] = "
";
for (var i = 0; i < dtEpaper.Table.length; i++) {
s[s.length] = "
";
s[s.length] = "
";
s[s.length] = "
";
s[s.length] = "
";
}
s[s.length] = "
Paper Code | Paper Name |
---|---|
" + dtEpaper.Table[i].Code + " | " + dtEpaper.Table[i].SubName + " |
s[s.length] = "
document.getElementById("<%= dvElectivePapers.ClientID%>").innerHTML = s.join("");
}
else {
document.getElementById('<%= dvElectivePapers.ClientID%>').style.display = 'none';
}
}
}
// -----------------------.cs Code with stored procedure caliing--------------
#region "BindElectivePapers"
[WebMethod]
public static Dictionary
{
CommonManger Obj = new CommonManger();
DataTable objEPaper = new DataTable();
objEPaper = Obj.GetTableWithParameter("SP_GetElectivePapers_ViaSpecialization", "@CrsID", CCode, "@Sem", SemId, "@CrsSpl", Spec);
if (objEPaper.Rows.Count > 0)
{
return JsonMethods.ToJson(objEPaper);
}
else
{
return null;
}
}
#endregion
No comments:
Post a Comment