newstar0101

导航

gridview增加计算列

字体变小 字体变大

方法一:  
  select   name,价格,数量*价格   as   总价   from   你的表  
  然后将结果绑定dataGridView  
  方法二:   
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
    e.Row.Cells(2).Text = (Convert.ToInt32(e.Row.Cells(0).Text) * Convert.ToDouble(e.Row.Cells(1).Text)).ToString()
End Sub

方法三:   
Dim newcol As New DataColumn("field3") 
newcol.Expression = "[field1] * [field2]"
mydatatable.Columns.Add(newcol)
datagrid1.DataSource = mydatatable
datagrid1.DataBind()  

posted on 2008-08-19 14:03  newstar0101  阅读(1321)  评论(0)    收藏  举报