如何将Count和Totalprice列添加到gridview? [英] how to add Count and Totalprice columns to gridview ?

查看:93
本文介绍了如何将Count和Totalprice列添加到gridview?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从databse中选择一列,然后将其放入数据表中,就像这样

I select column from databse and I put then in datatable like that

DataTable dtt = d.select("select ItemID,ItemName,SellingPrice,ImageUrl from TItem where ItemID in (" + oCookie.Value + ")");



然后像这样将它们放在gridview中



and after that I put them in the gridview like that

GridView2.DataSource =dtt;
 GridView2.DataBind();


现在我在网格中有三列

我的问题

如何在网格中也添加丝束

第一列是用于修改数量的文本框

第二列是总计,用于计算总价???????????

请帮我,我有很多时间要做,但我没有达到它


now I have three column in grid

my question

how to add tow column too to the grid

first column is textbox to modify the quantity

second column is the total to calculate the total price???????????

help me please I had I lot of time to do and I didn''t reach to it

推荐答案

hi,
您可以使用DataTable.Compute将评估公式添加到DataColumn.为了添加"Sum"列,您只需要向DataTable添加一列,然后使用Compute方法为该列定义一个公式.
http://msdn.microsoft.com/en-us/library/system. data.datatable.compute.aspx [ ^ ]
为了将文本框添加到网格,可以在网格中定义一个TemplateField,在其中放置一个文本框,然后定义一个事件处理程序以运行用于更改它的特定代码.

希望对您有帮助,
干杯

you can use DataTable.Compute to add an evaluating formula to a DataColumn. In order to add ''Sum'' column you need to just add a column to the DataTable and ,then, use Compute method to define a formula for that column.
http://msdn.microsoft.com/en-us/library/system.data.datatable.compute.aspx[^]
In order to add a textbox to your grid, you can define a TemplateField in your grid, put a textbox in it and then define an event handler to run a particular code for changing it.

I hope it helps,
Cheers


这篇关于如何将Count和Totalprice列添加到gridview?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆