首先在webservice中设置好WebMethod,即selectuserpwd(exec,i,j)方法
然后在客户代码中:
string exec="select * from userpwd";
???ds=new DataSet();
???ds=mbi.selectuserpwd(exec,1,10);
???dt=new DataTable();
???col=new DataColumn();
???col.ColumnName="姓名";
???col.DataType=System.Type.GetType("System.String");
???dt.Columns.Add(col);
???col=new DataColumn();
???col.ColumnName="地址";
???col.DataType=System.Type.GetType("System.String");
???dt.Columns.Add(col);
???col=new DataColumn();
???col.ColumnName="电话";
???col.DataType=System.Type.GetType("System.String");
???dt.Columns.Add(col);
??
???string strBody="<table><tr><td>";
???for(int j=0;j<ds.Tables["userpwd"].Rows.Count;j++)
???{
????row=dt.NewRow();
????row["姓名"]="<a href='view.aspx?id="+ds.Tables["userpwd"].Rows[j][0].ToString()+"'>"+ds.Tables["userpwd"].Rows[j][1].ToString()+"</a>";
????row["地址"]=ds.Tables["userpwd"].Rows[j][2].ToString();
????row["电话"]=ds.Tables["userpwd"].Rows[j][3].ToString();
????dt.Rows.Add(row);
????strBody+="<a href='view.aspx?id="+ds.Tables["userpwd"].Rows[j][0].ToString()+"'>"+ds.Tables["userpwd"].Rows[j][1].ToString()+"</a>";
????strBody+="?? "+ds.Tables["userpwd"].Rows[j][2].ToString()+"? "+ds.Tables["userpwd"].Rows[j][3].ToString()+"<br>";
????
???}
???this.DataGrid1.DataSource=dt;
???this.DataGrid1.DataBind();
???strBody+="</td></tr></table>";
???return strBody;
..
this.DataGrid1.CurrentPageIndex=e.NewPageIndex;
???this.DataGrid1.DataBind();
..
客户html代码
asp:DataGrid id="DataGrid1" runat="server" Width="400px" Height="152px" BorderColor="White" BorderStyle="Ridge"
BorderWidth="2px" CellSpacing="1" BackColor="White" CellPadding="3" GridLines="None" PageSize="4"
AllowPaging="True">
<FooterStyle ForeColor="Black" BackColor="#C6C3C6"></FooterStyle>
<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#9471DE"></SelectedItemStyle>
<ItemStyle ForeColor="Black" BackColor="#DEDFDE"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#E7E7FF" BackColor="#4A3C8C"></HeaderStyle>
<PagerStyle NextPageText="Next" PrevPageText="Preview" HorizontalAlign="Right" ForeColor="Black"
BackColor="#C6C3C6"></PagerStyle>
</asp:DataGrid
及调用函数Display()