如何在数据网格视图中进行分页 [英] how to make pagination in datagrid view
本文介绍了如何在数据网格视图中进行分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好先生...我有我的视图页面,其中我正在datagrid视图中检索数据,我有30个数据,但是我想在一个页面中显示10个数据,而在网页中以及前一个butonon上显示另一个1o ... .i正在发送我的查看页面源代码,以便您可以轻松地获得问题-
hello sir...i have my view page in which i am retrieving data in datagrid view and i have 30 data but i want to show 10 data in one page and another 1o in net page and previous buttoon also....i am sending my view page source code so that u can easily get the question-
<table border="1"><a href="viewpost.jsp"></a>
<table>
<tr bgcolor="#E8E8E8">
<td><b>ID</b></td>
<td><b>Name</b></td>
<td><b>Age</b></td>
<td><b>Gender</b></td>
<td><b>Address</b></td>
<td><b>Phone</b></td>
<td><b>Post</b></td>
<td colspan="2"><b>Action</b></td>
</tr>
<%! ResultSet rs = null;
%>
<%
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/sms", "root", "root");
String query = "select * from post";
Statement st;
st = con.createStatement();
ResultSet rs = st.executeQuery(query);
%>
<%
while (rs.next()) {
%>
<tr bgcolor="#D8D8D8">
<td width="50"><%=rs.getString(1)%></td>
<td width="50"><%=rs.getString(2)%></td>
<td width="50"><%=rs.getString(3)%></td>
<td width="50"><%=rs.getString(4)%></td>
<td width="50"><%=rs.getString(5)%></td>
<td width="50"><%=rs.getString(6)%></td>
<td width="50"><%=rs.getString(7)%></td>
<td><input type="submit" value="Edit" style="background-color:green;font-weight:bold;color:white;" önclick="editRecord(<%=rs.getString(1)%>)" ></td>
<td><input type="submit" value="Delete" style="background-color:red;font-weight:bold;color:white;" önclick="deleteRecord(<%=rs.getString(1)%>)" ></td>
</tr>
<%
}
%>
<%
}
catch(Exception e){
e.printStackTrace();
}
%>
</table>
我正在等待您的答复.
i am waiting for your response.
推荐答案
要在GridView中进行分页,可以在 ^ ]
For paging in GridView, CodeProject article is available at Paging in DataGridView[^]
这篇关于如何在数据网格视图中进行分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文