急!!gridview绑定dataset和hashtable问题

来源:百度知道 编辑:UC知道 时间:2024/09/12 15:38:13
我做了个 购物车 在购买界面是 点击购买 则在session["bus"]中创建相应商品的主键 和购买数量 最后给hashtable
点击查看购物车 我是用gridview显示数据的 要求显示 商品名称 价格 和数量 商品名称和价格 可以根据hashtable中存的主键 查询到 但是数量怎么显示?
2楼 能说说怎么通过模板调用方法 把数据显示出来?

不知道你的GridView是不是把Hashtable作为数据源,如果是的话, 那么本身就有数据量.然后你可以写个方法通过主键分别获得名称和价格.然后在GV的模板列里调用这个方法.

//补充

<asp:gridview id="TitleGridView"
datasourceid="TitleSqlDataSource"
autogeneratecolumns="false"
onrowdatabound="TitleGridView_RowDataBound"
runat="server">

<columns>

<asp:templatefield headertext="Type">
<itemtemplate>
<%# GetProductNameById(Eval("Id")) %>
</itemtemplate>
</asp:templatefield>

</columns>

</asp:gridview>

GetProductNameById是一个cs里面的public方法.

很简单的问题,自己看资料去