일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- DataGrid
- javascript
- 태그를 입력해 주세요.
- ASP
- 엑셀
- 마이크로소프트
- 오라클
- Winform
- c#
- SSRS
- replace()
- 이클립스
- MSSQL
- oracle
- 비주얼스튜디오
- windows
- CONVERT()
- microsoft
- Excel
- IIS
- 리포팅서비스
- 윈도우
- MS
- attr()
- 자바스크립트
- 윈폼
- 프로시저
- 단축키
- aspnet
- jQuery
- Today
- Total
DJ메탈짱™의 Free Style
[ASP.NET] GridView 페이징 (SqlDataSource 컨트롤 사용안함) 본문
1. ASPX
<asp:GridView ID="gvOrders" runat="server" AllowPaging="True" AutoGenerateColumns="False" EnableViewState="False" OnPageIndexChanging="gvOrders_PageIndexChanging" PageSize="20">
<Columns>
<asp:TemplateField HeaderText="No">
<ItemStyle Width="10px" CssClass="tabletit2" HorizontalAlign="Center" />
<ItemTemplate><%# (Container.DataItemIndex + 1).ToString() %></ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerSettings FirstPageText="<< First" LastPageText="Last >>" NextPageText="Next >" PreviousPageText="< Previous" Mode="NumericFirstLast" />
<asp:GridView>
2. ASPX.CS
private void GridViewBind()
{
SqlCommand cmdOrders = new SqlCommand();
cmdOrders.Connection = Con;
cmdOrders.CommandText = "SELECT * FROM Orders";
cmdOrders.Parameters.Add("@OrderID", SqlDbType.VarChar, 10);
cmdOrders.Parameters["@OrderID"].Value = strOrderID.Text ;
DataSet dsMain = new DataSet();
SqlDataAdapter daOrders = new SqlDataAdapter(cmdOrders);
daOrders.Fill(dsMain, "Orders");
gvOrders.DataSource = dsMain.Tables[0];
gvOrders.DataBind();
}
protected void gvOrders_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvRollBook.PageIndex = e.NewPageIndex;
GridViewBind() ;
}