0
蔭正從後端數據的表,現在我想這些數據如何將數據綁定到使用knockoutjs在C#中的WebForms
IAM正從後端數據綁定到表中的WebForms這樣
[WebMethod]
[ScriptMethod]
private string GetAll()
{
SqlConnection con = new SqlConnection(@"Data Source=DEVENV1;Initial Catalog=KnockoutData;Integrated Security=True");
SqlCommand cmd = new SqlCommand("select * from sampledb", con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
}
現在通過使用Web表單的jQuery阿賈克斯IAM獲取數據,這樣的事情...
<script type="text/javascript">
$(document).ready(function() {
$('#btnEdit').click(function() {
var viewModel;
$.ajax({
type: "GET",
url: "KnockoutJs.aspx/GetAll",
contentType: "application/json",
success: function (data) {
var result = JSON.parse(data);
}
});
});
<script>
現在怎麼這個數據綁定到下表,用knockoutJs的foreach
<table border="1">
<tr>
<th>Student Name</th>
<th>Roll No </th>
</tr>
</table>
看看這個淘汰賽[文檔](http://knockoutjs.com/documentation/foreach-binding.html) – Martyn0627 2013-02-11 09:50:35