请教关于淘宝API获取商品信息后分页的问题~在线等
小弟最近在做秒杀网站 通过淘宝API获取数据 现在已经获取成功 只是无法分页
private void BindHot()
{
string url = "http://gw.api.taobao.com/router/rest";
string appkey = Config.app_key;
string appsecret = Config.app_secret;
ITopClient client = new DefaultTopClient(url, appkey, appsecret);
TaobaokeItemsGetRequest req = new TaobaokeItemsGetRequest();
req.Fields = "num_iid,click_url";
req.Nick = Config.nick;
req.Pid = Config.pid;
req.Keyword = "打折秒杀";
req.StartPrice = "1";
req.PageSize = 15;
AspNetPager1.PageSize = Convert.ToInt32(req.PageSize);
req.EndPrice = "100";
req.Sort = "price_asc";
DataTable dt = new DataTable();
string[] LieMing = { "Title", "NumIid", "PicUrl", "Price", "ClickUrl", "Num", "FreightPayer" };
for (int i = 0; i < LieMing.Length; i++)
{
dt.Columns.Add(LieMing[i].ToString(), typeof(string));
}
for (int o = 0; o <10; o++)
{
TaobaokeItemsGetResponse response = client.Execute(req);
List<TaobaokeItem> tbis = response.TaobaokeItems;
for (int i = 0; i < response.TaobaokeItems.Count; i++)
{
DataRow dr = dt.NewRow();
dr["ClickUrl"] = tbis[i].ClickUrl.ToString();
Item tbdi = DetailProduct(tbis[i].NumIid.ToString());
dr["Num"] = tbdi.Num.ToString();
dr["FreightPayer"] = tbdi.FreightPayer.ToString() == "seller" ? "包邮" : "不包邮";
dr["Title"] = tbdi.Title.ToString();
dr["PicUrl"] = tbdi.PicUrl.ToString();
dr["Price"] = tbdi.Price.ToString();
dt.Rows.Add(dr);
}
}
AspNetPager1.RecordCount = dt.Rows.Count;
Session["dvlist"] = dt.DefaultView;
BindData();
}
protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
BindData();
}
private void BindData()
{
PagedDataSource pds = new PagedDataSource();
pds.AllowPaging = true;
pds.PageSize = AspNetPager1.PageSize;
pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
pds.DataSource = (DataView)Session["dvlist"];
Repeater1.DataSource = pds;
Repeater1.DataBind();
}
<webdiyer:AspNetPager ID="AspNetPager1" runat="server" AlwaysShow="True" CustomInfoHTML="" CustomInfoStyle="FONT-SIZE: 12px" HorizontalAlign="Center"
InputBoxStyle="width:19px" meta:resourcekey="AspNetPager1"
OnPageChanged="AspNetPager1_PageChanged" ShowCustomInfoSection="Left" Style="font-size: 14px" Width="95%">
</webdiyer:AspNetPager>