帮我写个分页的程序?(c# Sqlserver)
3个回答
展开全部
<%@ Import Namespace="System.Data"%>
<br><%@ Import Namespace="System.Data.SqlClient" %>
<br><script language="C#" runat="server">
<br>void Page_load()
<br>{
<br>if (!IsPostBack)
<br>{
<br>string strConnection = "server=127.0.0.1;";
<br>strConnection += "database=ztx;uid=sa;password=wxj;";
<br>SqlConnection sqlConnection1 = new SqlConnection(strConnection);
<br>string strSql = "select top 20 i_id,i_caption,i_count,substring(i_content,1,20) as i_content from content";
<br>SqlDataAdapter sqlAdapter = new SqlDataAdapter(strSql, sqlConnection1);
<br>DataSet objDataSet = new DataSet();
<br>sqlAdapter.Fill(objDataSet);
<br>ViewState["objDataSet"]=objDataSet
<br>bind();
<br>}
<br>}
<br>
<br>protected void abc(object source, DataGridPageChangedEventArgs e)
<br>{
<br>
<br>zhangtianxing.CurrentPageIndex = e.NewPageIndex;
<br>bind();
<br>}
<br>
<br> protected void button1(object sender, EventArgs e)
<br> {
<br> zhangtianxing.CurrentPageIndex += 1;
<br> bind();
<br> }
<br> private void bind()
<br> {
<br> DataSet objDataSet = (DataSet)ViewState["objDataSet"];
<br> zhangtianxing.DataSource = objDataSet;
<br> zhangtianxing.DataBind();
<br> }
<br></script>
<br><html>
<br><head>
<br><title>中国新闻搜索中心</title>
<br></head>
<br><body>
<br>
<br><form id="Form1" runat="server" >
<br><table><tr><td><asp:datagrid ID="zhangtianxing" runat="server" AllowPaging="True" PageSize="3" /> </td></tr><Tr><td>
<br><asp:LinkButton OnClick="button1" ID="LinkButton1" runat="server">LinkButton</asp:LinkButton> </td></tr></table>
<br></form>
<br></body>
<br></html>
<br><%@ Import Namespace="System.Data.SqlClient" %>
<br><script language="C#" runat="server">
<br>void Page_load()
<br>{
<br>if (!IsPostBack)
<br>{
<br>string strConnection = "server=127.0.0.1;";
<br>strConnection += "database=ztx;uid=sa;password=wxj;";
<br>SqlConnection sqlConnection1 = new SqlConnection(strConnection);
<br>string strSql = "select top 20 i_id,i_caption,i_count,substring(i_content,1,20) as i_content from content";
<br>SqlDataAdapter sqlAdapter = new SqlDataAdapter(strSql, sqlConnection1);
<br>DataSet objDataSet = new DataSet();
<br>sqlAdapter.Fill(objDataSet);
<br>ViewState["objDataSet"]=objDataSet
<br>bind();
<br>}
<br>}
<br>
<br>protected void abc(object source, DataGridPageChangedEventArgs e)
<br>{
<br>
<br>zhangtianxing.CurrentPageIndex = e.NewPageIndex;
<br>bind();
<br>}
<br>
<br> protected void button1(object sender, EventArgs e)
<br> {
<br> zhangtianxing.CurrentPageIndex += 1;
<br> bind();
<br> }
<br> private void bind()
<br> {
<br> DataSet objDataSet = (DataSet)ViewState["objDataSet"];
<br> zhangtianxing.DataSource = objDataSet;
<br> zhangtianxing.DataBind();
<br> }
<br></script>
<br><html>
<br><head>
<br><title>中国新闻搜索中心</title>
<br></head>
<br><body>
<br>
<br><form id="Form1" runat="server" >
<br><table><tr><td><asp:datagrid ID="zhangtianxing" runat="server" AllowPaging="True" PageSize="3" /> </td></tr><Tr><td>
<br><asp:LinkButton OnClick="button1" ID="LinkButton1" runat="server">LinkButton</asp:LinkButton> </td></tr></table>
<br></form>
<br></body>
<br></html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询