我使用網格視圖web控制的asp.net,即時通訊使用分頁控制,我處理了分頁事件,但它不顯示數據,如果我點擊2,3,4 ...等鏈接它不顯示一個結果set..it不給任何異常,但只是顯示沒有開的第一page.here是代碼:GridView分頁控制問題
public partial class Main : System.Web.UI.Page
{
protected string PostBackOption = "";
protected void Page_Load(object sender, EventArgs e)
{
this.check.Text = " ";
if (Page.IsPostBack)
{
PostBackOption = "$(\"#dialog\").dialog(\"open\");";
}
}
List<Allemployees> result1 = new List<Allemployees>();
protected void Button1_Click(object sender, EventArgs e)
{ // Show all the employees currently in the table
GridView1.DataSource = null;
GridView1.DataBind();
using (var db = new AdventureWorks2012_DataEntities())
{
List<Allemployees> result = new List<Allemployees>();
var query = from b in db.Employees
join p in db.People on b.BusinessEntityID equals p.BusinessEntityID
orderby p.BusinessEntityID
select new
{
b.BusinessEntityID,
p.FirstName,
p.LastName
};
foreach (var item in query)
{
Allemployees t1 = new Allemployees();
t1.BusinessEntityId = item.BusinessEntityID;
t1.FirstName = item.FirstName;
t1.LastName = item.LastName;
result1.Add(t1);
}
GridView1.DataSource = result1;
GridView1.DataBind();
}
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataSource = result1;
GridView1.DataBind();
}
}
感謝它的工作,但我有另一個問題,我有25個按鈕?_Click(null,null);事件..現在解決它? – 2013-05-12 09:04:19
請重新說出你的問題,對不起,我沒有得到它。 :( – jomsk1e 2013-05-12 09:07:09
我的意思是我有25個更多的按鈕處理程序,我怎麼能遇到它 – 2013-05-12 12:02:44