数据列表项数据绑定不正常

时间:2012-10-13 06:18:21

标签: asp.net vb.net c#-4.0

我使用以下代码更改按钮状态(启用或禁用)。但它适用于第一个控制,第二个和第三个控制状态没有改变。请帮我修复此错误。

If (e.Item.ItemType = DataControlRowType.DataRow) Then
            Dim status As Button = CType(e.Item.FindControl("btnstatus"), Button)
            If status IsNot Nothing Then
                If status.Text = "Ready" Then
                    status.Enabled = True
                ElseIf status.Text = "Assigned" Then
                    status.Enabled = False
                Else
                    status.Enabled = False
                End If
            End If

            'do what ever you want to do here using the value of your label
        End If

1 个答案:

答案 0 :(得分:0)

试试这个:

If e.Item.ItemType = ListItemType.Item Or _
             e.Item.ItemType = ListItemType.AlternatingItem Then

//Your Code Here

End If