您的位置:首页 > 编程语言 > C#

c#下调用webservice在客户端利用datagrid本身功能分页

2006-04-21 12:46 435 查看
服务器端:

public DataSet selectuserpwd(string exec)
{
this.sqlConnection1.Open();
this.sqlDataAdapter1.SelectCommand.CommandText=exec;
DataSet ds1=new DataSet();
this.sqlDataAdapter1.Fill(ds1,"userpwd");

return ds1

}

客户端:

mbi=new TableWebApplication1.localhost.Service1();
mbi.Credentials=System.Net.CredentialCache.DefaultCredentials;
ds=new DataSet();
ds=mbi.selectuserpwd("select * from userpwd");
this.DataGrid1.DataSource=ds;
this.DataGrid1.DataBind();
this.DataGrid1.PageIndexChanged+=new DataGridPageChangedEventHandler(DataGrid1_PageIndexChanged);

private void DataGrid1_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
{
this.DataGrid1.CurrentPageIndex=e.NewPageIndex;
this.DataGrid1.DataBind();
}

客户端页面的html:

<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 200px; POSITION: absolute; TOP: 72px" runat="server" Width="376px" Height="184px" PageSize="3" AllowSorting="True" AllowPaging="True" AutoGenerateColumns=False>

?Columns>
?asp:BoundColumn DataField="name" HeaderText="姓名"></asp:BoundColumn>
?asp:BoundColumn DataField="address" HeaderText="地址"></asp:BoundColumn>
?asp:BoundColumn DataField="tel" HeaderText="电话"></asp:BoundColumn>
?/Columns>

</asp:DataGrid>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐