我正在尝试使用带有格式化的产品 ID 和数量字符串的 cookie。我已经设置好进行查询并获取 cookie 中每个项目的表数据。现在我需要获取数据,将其连接到列表视图。cookie 看起来像:1x4:23x9...
public partial class checkout : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
productTableAdapter ad = new productTableAdapter();
HttpCookie c = Request.Cookies["cart"];
if (c == null)
{
}
else
{
string items = c.Value;
new prod(items);
if (items.Length > 0)
{
char[] delimiterChars = {':'};
string[] orders = items.Split(delimiterChars);
char[] del = {'x'};
ObjectDataSource ods = new ObjectDataSource();
foreach( string s in orders){
string[] proc = s.Split(del);
int id = int.Parse(proc[0]);
int quant = int.Parse(proc[1]);
DataSet1.productDataTable td = ad.GetDataByPID(id);
// something..?
}
ListView1.DataSource = ods;
ListView1.DataBind();
}
}
}
}