第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

DataGrid 不會(huì)顯示下一頁(yè)的數(shù)據(jù)

DataGrid 不會(huì)顯示下一頁(yè)的數(shù)據(jù)

C#
紅糖糍粑 2021-06-11 14:12:54
無(wú)論我單擊哪個(gè)頁(yè)面,我的 DataGrid 都會(huì)顯示來(lái)自第一頁(yè)的數(shù)據(jù),我已經(jīng)搜索了解決方案,但沒(méi)有任何效果。我已經(jīng)把BindGrid對(duì)!IsPostBack和重新綁定在網(wǎng)格grid1_PageIndexChanging。這是我的代碼:protected void Page_Load(object sender, EventArgs e){    if (!IsPostBack)    {        BindGrid();    }}private int GetNumItems(){    SqlConnection con = new SqlConnection();    con.ConnectionString = gc.GetWebConfigConnectionStringAIS();    con.Open();    string query = "SELECT COUNT(*) FROM dbo.TestingLatihan";    SqlCommand cmd = new SqlCommand(query, con);    Int32 totalRow = (Int32)cmd.ExecuteScalar();    con.Close();    return totalRow;}protected void grid1_PageIndexChanging(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e){    grid1.CurrentPageIndex = e.NewPageIndex;    BindGrid();}private void BindGrid() {    grid1.VirtualItemCount = GetNumItems();    grid1.PageIndexChanged += new DataGridPageChangedEventHandler(grid1_PageIndexChanging);    SqlConnection con = new SqlConnection();    con.ConnectionString = gc.GetWebConfigConnectionStringAIS();    con.Open();    string query = "SELECT * FROM dbo.TestingLatihan";    SqlCommand cmd = new SqlCommand(query, con);    SqlDataAdapter myAdapter = new SqlDataAdapter(cmd);    DataTable dt = new DataTable();    myAdapter.Fill(dt);    grid1.DataSource = dt;    grid1.DataBind();    con.Close();  }和我的 .aspx<asp:DataGrid ID="grid1" runat="server" AutoGenerateColumns="False"CellPadding="4" ForeColor="#333333" Width="100%" OnItemCommand="dtgItemCommand" AllowPaging="True" PageSize="5" AllowCustomPaging="True" OnPageIndexChanged="grid1_PageIndexChanging" EnableViewState="true">   <AlternatingItemStyle CssClass="tdgenap" />   <ItemStyle CssClass="tdganjil" HorizontalAlign="Center" />      <HeaderStyle HorizontalAlign="Center" Height="30px" CssClass="tdjudul"></HeaderStyle>          <Columns>            
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 245 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)