转换后,模板列上的内容就是Label控件了
肯定能读到其中的Label,打开页面的源代码看一下ID
像你这个ID就是Lab_Did用((Label)e.Item.cells[X].findcontrol("Lab_Did")).text 读取
肯定能读到其中的Label,打开页面的源代码看一下ID
像你这个ID就是Lab_Did用((Label)e.Item.cells[X].findcontrol("Lab_Did")).text 读取
调试欢乐多
Lable是一个类型,不能用坐表达式。
Dim Did As String
Did= ((Label)e.Item.Cells(2).findcontrol("Lab_Did")).text (Label)e应该有问题,底下有蓝色曲线,还望指教,以前确实没用过。
如上,模板列需要用强制转换一下类型。
你把类型换为你的模块列就行了VB.NET可以有些关键字大小字不同
是c#的写法,
vb的是:
Did= ctype(e.Item.Cells(2).findcontrol("Lab_Did"),Label).text
我就像上面那样转的,为什么不可以呢???救命呀!!!郁闷
<asp:TemplateColumn HeaderText="机构编码">
<ItemTemplate>
<asp:Label id=Label2 runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.DEPT_ID") %>'>
</asp:Label>
</ItemTemplate>
html源码如上,我在.vb里这样写:
Dim Did As String
Did= ((Label)e.Item.Cells(2).findcontrol("Label2")).text
怎么不可以呢?