C# 更改页面后,RadGrid分页无法正常工作
我在我的ASP.Net应用程序中有一个RadGrid,我已经将AllowPaging设置为True,PageSize设置为10,现在每个RadGridPage加载10个项目,这正是我想要的,但只要我按下下一页按钮(箭头look按钮),就不会加载任何内容,RadGrid将变为空。 我怎样才能使它正常工作C# 更改页面后,RadGrid分页无法正常工作,c#,asp.net,telerik,radgrid,C#,Asp.net,Telerik,Radgrid,我在我的ASP.Net应用程序中有一个RadGrid,我已经将AllowPaging设置为True,PageSize设置为10,现在每个RadGridPage加载10个项目,这正是我想要的,但只要我按下下一页按钮(箭头look按钮),就不会加载任何内容,RadGrid将变为空。 我怎样才能使它正常工作 protected void Page_Load(object sender, EventArgs e) { PopulateGridOnLoad(); } pri
protected void Page_Load(object sender, EventArgs e)
{
PopulateGridOnLoad();
}
private void PopulateGridOnLoad()
{
rgCustomers.DataSource = odsCustomers;
// your datasource type
rgCustomers.MasterTableView.VirtualItemCount = 28;
//your datasource type total/count
rgCustomers.CurrentPageIndex = rgCustomers.MasterTableView.CurrentPageIndex;
rgCustomers.Rebind();
}
protected void grdName_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
rgCustomers.DataSource = odsCustomers;
// your datasource type
rgCustomers.MasterTableView.VirtualItemCount = 28;
//your datasource type total/count
rgCustomers.CurrentPageIndex = rgCustomers.MasterTableView.CurrentPageIndex;
//Donot rebind here
}
protected void btnLoad_Click(object sender, EventArgs e)
{
odsCustomers.SelectParameters["CustomerFullName"].DefaultValue = txtFullName.Text;
odsCustomers.SelectParameters["CustomerMelliCode"].DefaultValue = txtMelliCode.Text;
odsCustomers.SelectParameters["CustomerHomeAddress"].DefaultValue = txtHomeAddressPart.Text;
odsCustomers.SelectParameters["CustomerWorkAddress"].DefaultValue = txtWorkAddressPart.Text;
rgCustomers.DataSource = odsCustomers;
rgCustomers.DataBind();
}
您需要定义“OnnedDataSource”radgrid事件,在该事件中您应该重置网格的数据源
protected void RadGrid_NeedDataSource(object sender, EventArgs e)
{
IsNeedDataSource = true;
}
在pageOnPreRender
事件中,您应该执行以下操作:
protected override void OnPreRender(object sender, EventArgs e)
{
DriverLinksGrid.DataSource = value;
DriverLinksGrid.DataBind();
}
我不是舒尔,也许您可以在
OnNeedDataSource
事件中绑定数据。但是DataBind()
方法可能不可用。您必须在设计中设置网格的以下属性
<telerik:RadGrid ID="grdName"
AllowPaging="True"
AllowCustomPaging="True"
VirtualItemCount="0" PageSize="15" >
加载c#.net时填充网格
重写数据源vb.net
Protected Sub grdName_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles grdName.NeedDataSource
grdName.DataSource = source ' your datasource type
grdName.MasterTableView.VirtualItemCount = source.Total 'your datasource type total/count
grdName.CurrentPageIndex = grdName.MasterTableView.CurrentPageIndex
'Donot rebind here
End Sub
重写数据源c#
经过很长一段时间我找到了解决方案,这个问题涉及到两个小问题:
1.我设置了DataSource(在代码中)和DataSourceID(属性),但它们不能很好地协同工作
2.我将AllowPaging和AllowCustomPaging都设置为true,当它们都为true时,两者都不起作用:)这是telerik团队,你知道,但它们很棒,我开玩笑的在数据绑定的地方也给出代码。我希望你配置了RadScriptManager和RadAjaxManager设置properly@PravinPawar我没有,你能告诉我怎么做吗?遵循这一点很有帮助,但我仍然不能使用RadGrid导航按钮,带编号的按钮正在工作,但箭头按钮不起作用。RadGrid为我做了什么?我怀疑这是一个好的解决办法
private void PopulateGridOnLoad()
{
grdName.DataSource = source;
// your datasource type
grdName.MasterTableView.VirtualItemCount = source.Total;
//your datasource type total/count
grdName.CurrentPageIndex = grdName.MasterTableView.CurrentPageIndex;
grdName.Rebind();
}
Protected Sub grdName_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles grdName.NeedDataSource
grdName.DataSource = source ' your datasource type
grdName.MasterTableView.VirtualItemCount = source.Total 'your datasource type total/count
grdName.CurrentPageIndex = grdName.MasterTableView.CurrentPageIndex
'Donot rebind here
End Sub
protected void grdName_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
grdName.DataSource = source;
// your datasource type
grdName.MasterTableView.VirtualItemCount = source.Total;
//your datasource type total/count
grdName.CurrentPageIndex = grdName.MasterTableView.CurrentPageIndex;
//Donot rebind here
}