我想用一些基本數據創建一個Telerik RadGrid控件,並使用提供的簡單數據綁定方法here。Telerik Grid在ASP.NET WebForms回發後沒有顯示數據
<div id="divRadGrid">
<telerik:RadGrid ID="RadGrid1" runat="server" OnSortCommand="RadGrid1_SortCommand" AllowSorting="True"></telerik:RadGrid>
</div>
這是後面的代碼。當用戶點擊運行按鈕時,一切正常。但是,如果我單擊網格內的任何事件(例如在列上排序),則會看到頁面刷新,但網格不顯示任何內容。
任何建議將非常感激。
using System;
using System.Data;
using System.Collections.Generic;
using Telerik.Web.UI;
namespace TelerikDemoWebAppBlank2
{
public partial class Default : System.Web.UI.Page
{
public DataTable SalespersonProductionDT { get; set; }
public DataTable NewBusinessDT { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
}
protected void BtnRun_Click(object sender, EventArgs e)
{
getData();
processNewBusiness();
}
protected void RadGrid1_SortCommand(object sender, GridSortCommandEventArgs e)
{
dataBindGrid(RadGrid1, NewBusinessDT);
}
private void getData()
{
SalespersonProductionDT = new DataTable();
Sprocs._pDash_SalespersonProduction(BeginDate.SelectedDate.Value, EndDate.SelectedDate.Value, SalespersonProductionDT);
NewBusinessDT = new DataTable();
Sprocs._pDash_NewBusiness(BeginDate.SelectedDate.Value, EndDate.SelectedDate.Value, NewBusinessDT);
}
private void processNewBusiness()
{
dataBindChart(RadHtmlChart3, NewBusinessDT);
dataBindGrid(RadGrid1, NewBusinessDT);
}
private void dataBindChart(RadHtmlChart radHtmlChart, DataTable dt)
{
radHtmlChart.DataSource = dt;
radHtmlChart.DataBind();
}
private void dataBindGrid(RadGrid radGrid, DataTable dt)
{
radGrid.DataSource = dt;
radGrid.DataBind();
}
}
}
嘗試做你的IsPostBack檢查,並在頁面加載方法結合或改變數據表是靜態 – MethodMan
也許你的問題是'postback'。檢查這篇文章http://stackoverflow.com/questions/34544500/get-text-value-from-textbox-after-value-text-changed-server-side –
@MethodMan,如何將我的DataTable更改爲靜態幫助? – Pavel