为什么'索引'总是返回值0,尽管报价器正在运行并且存在'索引=索引+ 1'的语句?索引值仍然为0
'Dim index as integer = 0
'EDIT
Dim GridRowIndex as integer
Protected Sub TickerAnnouncement_Tick(sender As Object, e As System.EventArgs) Handles TickerAnnouncement.Tick
lblAnnouncementFooter.Text = GridView1.Rows(index).Cells(0).Text
'index = index + 1
If GridRowIndex> GridView1.Rows.Count Then GridRowIndex = 0
End Sub
我已将打勾打开,但索引仍然返回0值。
---加成---
我有一个叫做 'IndexValue' 属性:
Public Property IndexValue() As Integer
Get
Dim s As Integer = DirectCast(ViewState("GridRowIndex"), Integer)
Return If(ViewState("GridRowIndex") Is Nothing, 0, CInt(ViewState("GridRowIndex")) + 1)
End Get
Set(value As Integer)
ViewState("GridRowIndex") = value
End Set
End Property
您是否确定该语句实际执行?你是怎么确定的?你有没有机会声明一个名为'index'的局部变量?右键单击本地'index'变量并选择“转到定义”。它跳到哪里? – 2012-03-20 15:38:20
这是什么,Winforms,ASP.NET,WPF,...?如果它是ASP.NET,那么显然为什么它总是0.所有变量,控件(包括页面本身)都会在页面呈现给客户端时立即处理(HTTP是无状态的)。 – 2012-03-20 15:38:50
@KonradRudolph:执行了所有语句,但仅从GridView1返回了行(0)的值。 – 2012-03-20 15:40:29