[.NET] 抓取GridView的TemplateField的Label

作者: because25 (口苗)   2015-10-29 17:20:26
請輸入專案類型(網站專案或者應用程式專案):ASP.NET VB.NET
請教前輩
我想要抓取 GridView 的 TemplateField 中的 Label 控制項的值
可是一直失敗,也查了好多資料,一直沒辦法成功
目的是GridView某欄位(值只有0.1.2)
顯示時我可以改塞入不同的對映資料
我是在RowDataBound事件中作抓取動作,有試過下列抓法
Dim lb As Label
lb = CType(GridView1.Rows(e.RowIndex).Cells(5).FindControl("Label1"), Label)
但是 e.RowIndex 不是這事件的成員
請問我是事件選擇錯誤了嗎?
(有做過沒有TemplateField的抓取e.Row.Cells(5).Text 就沒問題)
還是語法錯誤了?
謝謝~
作者: because25 (口苗)   2015-10-30 09:46:00
感謝~補上For i As Integer = 0 To GridView1.Rows.Count -1GridView1.Rows(i).Cells(0).FindControl("Label1")且不能加上 e.Row.RowType 的判斷 不然列數會跑掉

Links booklink

Contact Us: admin [ a t ] ucptt.com