不使用AJAX将数据从数据库发布到后面的代码中的html [英] post a data from database to a html in code behind without using AJAX
本文介绍了不使用AJAX将数据从数据库发布到后面的代码中的html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我有一个名为最新消息的HTML表,我想发布数据库表中的数据在页面加载事件中从codebehind(newsCafe.aspx.cs)到HTML表格(ASPX)。
任何建议。
在PHP中,我使用AJAX完成了这项工作。但是在ASP.NET中我想在CodeBehind中创建它。
任何建议......
Hello there,
I have a HTML table called "Latest news" and i wanted to post the data from database table to the HTML table (ASPX) from codebehind(newsCafe.aspx.cs) on a page load event.
Any suggestion.
In PHP i had done this using AJAX. But in ASP.NET i want make this in CodeBehind.
Any suggestion...
推荐答案
为何选择html表?使用ASP.NET GridView或Repeater
查看以下链接获取示例代码
如何使用C#中的SQL语句填充DataGridView,GridView [ ^ ]
请注意,ASP.NET GridView已呈现作为HTML表传递给客户端(浏览器),它很容易使用。
如果您还需要使用html表格检查以下链接
http://stackoverflow.com/questions/19602917/how-to-display-data-in-html-table-in-asp-net 一> [ ^ ]
http://stackoverflow.com/questions/8398604/how-do-i-bind-data-from-the-database-table-to-an -html-control-like-div-or-tab [ ^ ]
Why html table? use ASP.NET GridView or Repeater
check below link for sample code
How to populate DataGridView, GridView with SQL statement in C#[^]
note that ASP.NET GridView is rendered as a HTML Table when passed to the client (browser) and it is easy to use.
if you still need to go with html table check below links
http://stackoverflow.com/questions/19602917/how-to-display-data-in-html-table-in-asp-net[^]
http://stackoverflow.com/questions/8398604/how-do-i-bind-data-from-the-database-table-to-an-html-control-like-div-or-tab[^]
试试这个例子.. :)
Javascript
try this example.. :)
Javascript
function BindTable() {
.ajax({
type: POST,
url: newsCafe.aspx / GetData,
contentType: application / json; charset = utf -8,
data:{},
dataType: json ,
成功:功能(数据){
.ajax({ type: "POST", url: "newsCafe.aspx/GetData", contentType: "application/json;charset=utf-8", data: {}, dataType: "json", success: function (data) {
这篇关于不使用AJAX将数据从数据库发布到后面的代码中的html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文