看板 Visual_Basic 關於我們 聯絡資訊
請輸入專案類型(網站專案或者應用程式專案):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 就沒問題) 還是語法錯誤了? 謝謝~ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 59.124.54.20 ※ 文章網址: https://www.ptt.cc/bbs/Visual_Basic/M.1446110428.A.735.html
cf1064: http://pastebin.com/juPnad5Y 10/29 21:02
cf1064: http://pastebin.com/SEVqFbYL 10/29 21:12
because25: 感謝~ 10/30 09:46
because25: 補上For i As Integer = 0 To GridView1.Rows.Count -1 10/30 09:47
because25: GridView1.Rows(i).Cells(0).FindControl("Label1") 10/30 09:48
because25: 且不能加上 e.Row.RowType 的判斷 不然列數會跑掉 10/30 09:49