麻辣家族討論版版's Archiver

child 發表於 2010-8-11 14:43

gridview增加計算列(ASP.NET)

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

因為會從標題列開始計算會造成異常,請教如何從標題列下面開始計算,很謝謝大家的幫忙^^

Luc 發表於 2010-8-15 00:24

處理前先判斷是不是資料列
If e.Row.RowType = DataControlRowType.DataRow Then
    ... '略
End If

child 發表於 2010-8-16 08:49

[quote]處理前先判斷是不是資料列
If e.Row.RowType = DataControlRowType.DataRow Then
    ... '略
End If
[size=2][color=#999999]Luc 發表於 2010-8-15 00:24[/color] [url=http://forum.twbts.com/redirect.php?goto=findpost&pid=5161&ptid=1043][img]http://forum.twbts.com/images/common/back.gif[/img][/url][/size][/quote]


    謝謝Luc 的幫忙^^

頁: [1]

麻辣家族討論版版為 麻辣學園 網站成員  由 昱得資訊工作室 © Since 1993 所提供