[.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