我有以下代码如何使用Java脚本绑定网格我想调用aspx.cs代码并检索数据并使用网格绑定而无需回发请帮助我。我是新的asp.net请帮帮我。我打电话给这个方法但没有成功
<script type='text/javascript'>
$(document).ready(function () {
bindjs();
})
function bindjs() {
PageMethods.BindGrid(Success, Failure);
}
function Success(result) {
alert(result);
}
function Failure(error) {
alert(error);
}
</script>
和我的Asp.cs方法是
[WebMethod]
public static DataTable BindGrid()
{
con = new SqlConnection(constr);
da = new SqlDataAdapter("select tblStudent.student_id,tblStudent.student_name,tblStudent.father_name," +
"tblStudent.Cell,tblStudent.parents_cell,tblStudent.admission_date,tblclassinfo.class_name,address_student" +
" from tblStudent inner join tblclassinfo on tblStudent.class_id = tblclassinfo.class_id", con);
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}
答案 0 :(得分:1)
您必须更改要从
继承的cs类public class Service1 : System.Web.Services.WebService
然后你的方法如下
<WebMethod()> _
void BindGrid(string bookingInformation) {
//your code here
}