datatables插件使用服务器端数据源不会在第2页上保持状态 [英] datatables plugin wont hold state on page 2 using server side datasource
本文介绍了datatables插件使用服务器端数据源不会在第2页上保持状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用jquery datatables插件,它很棒,直到我使用转发器ItemCommand进行更改。它似乎只保存插件第一页的数据..即。第1页,而不是2,3,4 .... *页面..奇怪的是下拉值保留在下拉列表中,但下拉列表的选定值默认为位置0(两者都生成并分配通过sql数据集)..
这是我的代码..
Im using the jquery datatables plugin, and its great, until I make a change using a repeater ItemCommand. It seems to only hold the data for the first page of the plugin.. ie. page 1 and not the 2, 3, 4.... * pages.. The wierd thing is the drop down values remain in the drop down, but the selected value of the drop down defaults to position 0 (both are generated and assigned via sql dataset)..
Here is my code..
<pre> /// ************************************************************************
/// <summary>
/// Gets the data from the repeater responce.
/// </summary>
/// ************************************************************************
protected void testRepeater_ItemCommand(object source, RepeaterCommandEventArgs e)
{
// Update category
if (e.CommandName == "category")
{
var arguments = (string)e.CommandArgument;
var arg = arguments.Split(new[] { ';' });
Session["PersonId"] = arg[0];
Session["CategoryId"] = arg[1];
int personID = Converter.ToInteger(arg[0]);
int categoryId = Converter.ToInteger(arg[1]);
using (TrialProvider tp = new TrialProvider())
{
tp.UpdateCategory(CategoryId, PersonID);
}
}
}
/// ************************************************************************
/// <summary>
/// Populates drop-down with category details.
/// </summary>
/// ************************************************************************
protected void categoryList_DataBinding(object sender, System.EventArgs e)
{
DropDownList categoryList = (DropDownList)(sender);
using (TrialProvider tp = new TrialProvider())
{
DataSet ds = tp.GetAllTrialCategories();
// Add the items to the list
foreach (DataRow dr in ds.Tables[0].Rows)
{
categoryList.Items.Add(new ListItem(Converter.ToString(dr["Category"]), Converter.ToString(dr["CategoryId"])));
// Set the selected property
categoryList.SelectedValue = Eval("CategoryId").ToString();
}
}
}
这是我的客户边码..
Here is my client side code..
<pre><asp:Repeater ID="testRepeater" runat="server">
<HeaderTemplate>
<table id="test-table" class="display">
<thead>
<td>First Name</td>
<td>Surname</td>
<td>Date of Birth</td>
<td>State</td>
<td>Postcode</td>
<td>Email</td>
<td>Category</td>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# DataBinder.Eval(Container, "DataItem.FirstName") %></td>
<td><%# DataBinder.Eval(Container, "DataItem.Surname") %></td>
<td><%# DataBinder.Eval(Container, "DataItem.DOB", "{0:d/M/yyyy}") %></td>
<td><%# DataBinder.Eval(Container, "DataItem.State") %></td>
<td><%# DataBinder.Eval(Container, "DataItem.Postcode") %></td>
<td><%# DataBinder.Eval(Container, "DataItem.Email") %></td>
<td>
<asp:DropDownList ID="categoryList"
CommandName="category"
CommandArgument='<%# Eval("PersonId") + ";" + Eval("CategoryId") %>'
runat="server"
AutoPostBack="true"
OnDataBinding="categoryList_DataBinding"></asp:DropDownList>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater
>
推荐答案
这可能是因为它是只读的Repeater控件。尝试将Repeater控件更改为DataGrid或Grid View并验证。
It's probably because of Repeater control as it's read only. Try changing Repeater control to DataGrid or Grid View and verify.
这篇关于datatables插件使用服务器端数据源不会在第2页上保持状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文