对象必须使用列表实现 IConvertible Error
我之前发布了一个关于使用列表存储数据然后通过会话变量传递数据的问题,到目前为止我有以下代码:
默认页面:
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
var basketItems = new List<int>();
basketItems.Add(1);//I need to get the ID of the book I am selecting from the gridView
Session["BasketList"] = basketItems;
Response.Redirect("Basket.aspx");
}
购物篮页面:
protected void Page_Init(object sender, EventArgs e)
{
var basketListItems = (List<int>)Session["BasketList"];
}
然后,我使用以下语法在购物篮页面上有一个 gridView 控件:
SelectCommand="SELECT * FROM [tblBook] WHERE ([BookID] = ?)">
我认为这会匹配将数据库中的 bookID 替换为 gridView 中 bookID 的 ID,然后输出书籍。
基本上我需要能够单击 gridview 上的选择,然后获取已单击的书籍的 id,然后将其发送到购物篮页面,在该页面中可以从书籍表中显示书籍信息。
I posted a question earlier about a using a list to store data then pass it through a session variable I have this code so far:
Default page:
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
var basketItems = new List<int>();
basketItems.Add(1);//I need to get the ID of the book I am selecting from the gridView
Session["BasketList"] = basketItems;
Response.Redirect("Basket.aspx");
}
Basket Page:
protected void Page_Init(object sender, EventArgs e)
{
var basketListItems = (List<int>)Session["BasketList"];
}
Then I have a gridView control on the basket page using this syntax:
SelectCommand="SELECT * FROM [tblBook] WHERE ([BookID] = ?)">
I thought this would match the bookID from the database to whatever the ID from the bookID in the gridView is, then output the books.
Basically I need to be able to click select on the gridview and then take the id of the book that has been clicked and then send it to the basket page where the book info can be displayed from the book table.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 List 的通用版本代替 List;
Use generic version of List instead List<int>