我正在使用asp.net,因为数据很大我最初使用jquery显示进度条,然后通过ajax调用页面并希望加载转发器控件。无法实现,请寻求帮助 ASPX PART:
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<table>
<asp:Repeater ID="Repeater2" runat="server">
<HeaderTemplate>
<thead>
<tr>
<td>Category Name</td>
</tr>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# Eval("CategoryName")%></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
</div>
</ItemTemplate>
第二部分的VB代码:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim requestType As String = Request.QueryString("type")
If Not String.IsNullOrEmpty(requestType) Then
Select Case requestType.ToUpper
Case "REPEATORLOAD"
Repeater1.DataSource = GenerateBinDetails()
Repeater1.DataBind()
End Select
End If
End Sub
AJAX SCRIPT PART:
var urlPath = "../views/Reports/RegionalStockHoldings.aspx?type=repeatorLoad"
$.ajax({
url: urlPath,
type: "POST",
cache: false
}).done(function (html) {
debugger;
//how can i bind it to my repeator control , I am getting the whole html data of the page.
});
答案 0 :(得分:0)
我不认为您可以从您提供的jQuery代码绑定转发器控件。
但是,你可以做的是将你的绑定代码移动到RegionalStockHoldings.aspx页面上的WebMethod。这就是
<System.Web.Services.WebMethod> _
Public Sub BindRepeater()
Repeater1.DataSource = GenerateBinDetails()
Repeater1.DataBind()
End Sub
然后,您可以从jQuery调用中调用此代码,如此
var urlPath = "../views/Reports/RegionalStockHoldings.aspx/BindRepeater"
$.ajax({
url: urlPath,
type: "POST",
cache: false
}).done(function (html) {
debugger;
alert("bound repeater");
});