簡體   English   中英

ASP.net Vb.Net Label.Text不更新

[英]ASP.net Vb.Net Label.Text not updating

在我的VB.net ASP應用程序中,我有一些ASPTREEVIEW,在頁面加載時有一個Label,我為其設置了一些值。 單擊任何行后,我捕獲該值並將其分配給標簽。

但是突然之間,標簽值並沒有根據所選值進行更新。 好像我通過調試值進行檢查一樣,值也會更改,但是當我使用Lable.text = selected_value ...時,它會設置值,但實際上在html頁面上並沒有更改。 HTML顯示了舊值。

會有什么問題,我沒有得到。

Imports DevExpress
Imports DevExpress.Xpo
Imports DevExpress.Data
Imports DevExpress.Data.Filtering
Imports System.Data

Partial Class _Default
    Inherits System.Web.UI.Page

    Public testvar As Integer = 35

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim xpcol As New XPCollection(Of WCSOEE.WcsGCObject)
        Dim GCObj1 As WCSOEE.WcsGCObject
        Dim Filter1 As New DevExpress.XtraCharts.DataFilter
        Dim SelectedGCObject As WCSOEE.WcsGCObject
        Filter1.ColumnName = "Oid"
        Filter1.Condition = XtraCharts.DataFilterCondition.Equal

        Filter1.Value = Label2.Text
        If Label2.Text = "" Then
            Label2.Text = 10
        End If
        For Each Siris As DevExpress.XtraCharts.Series In WebChartControl1.Series
            '  WebChartControl1.Series(Siris.Name).DataFilters.Item(0).Value = CInt(Label2.Text)
        Next


        Dim masterKeyvalue As DevExpress.Web.ASPxTreeList.TreeListNode = ASPxTreeList1.FocusedNode
        If masterKeyvalue IsNot Nothing Then
            SelectedGCObject = masterKeyvalue.DataItem
        Else
            SelectedGCObject = xpcol.Object(31)
        End If

        ' MsgBox(SelectedGCObject.GCName)
        MsgBox(Label2.Text)

        If IsPostBack = False Then
            Label2.Text = calculatehours(SelectedGCObject.Oid)
        End If

    End Sub

    Protected Function calculatehours(Oid As Integer)
        xpocolLogAvailability.Session = DevExpress.Xpo.XpoDefault.Session
        Dim logavail As New XPCollection(Of WCSOEE.LogAvailability)
        Dim gcobjlist As New XPCollection(Of WCSOEE.WcsGCObject)
        gcobjlist.Filter = CriteriaOperator.Parse("[Oid]=?", Oid)
        Dim filter As CriteriaOperator
        Dim ds As New DataTable
        Dim Series As New DevExpress.XtraCharts.Series
        Dim Filter1 As New DevExpress.XtraCharts.DataFilter
        ' Label2.Text = Oid


        logavail.Filter = CriteriaOperator.Parse("GCObject.Oid=?", Oid)
        Filter1.ColumnName = "Oid"
        Filter1.Condition = XtraCharts.DataFilterCondition.Equal
        Filter1.Value = Oid
        Dim arr1(32) As Long
        'For i As Int16 = 1 To 32
        '    arr1(i) = 0
        'Next
        'For Each gcobj As WCSOEE.LogAvailability In logavail
        '    arr1(gcobj.Status) = arr1(gcobj.Status) + gcobj.Duration
        'Next= ""
        'ds.Columns.Add(New DataColumn("Name", System.Type.GetType("System.Int32")))



        For Each Siris As DevExpress.XtraCharts.Series In WebChartControl1.Series

            WebChartControl1.Series(Siris.Name).DataFilters.Item(0).Value = Oid

        Next
        WebChartControl1.RefreshData()

        'For i As Int16 = 1 To 32
        '    ds.Rows.Add(i, arr1(i))
        'Next

        'ASPxListBox1.DataSource = ds
        'ASPxListBox1.DataBind()
        Return Oid
    End Function

    Protected Sub ASPxTreeList1_CustomCallback(sender As Object, e As DevExpress.Web.ASPxTreeList.TreeListCustomCallbackEventArgs) Handles ASPxTreeList1.CustomCallback

    End Sub

    Protected Sub ASPxTreeList1_FocusedNodeChanged(sender As Object, e As System.EventArgs) Handles ASPxTreeList1.FocusedNodeChanged
        Dim masterKeyvalue As DevExpress.Web.ASPxTreeList.TreeListNode = ASPxTreeList1.FocusedNode
        Dim SelectedGCObject As WCSOEE.WcsGCObject = masterKeyvalue.DataItem
        ' MsgBox(SelectedGCObject.GCName)

        If IsPostBack Then
            Label2.Text = calculatehours(SelectedGCObject.Oid)

        End If

        MsgBox(IsPostBack)
        MsgBox(Label2.Text)


    End Sub
End Class

發布一些代碼,以便我們可以准確地看到您所做的事情,到目前為止,什么都沒有看到,請確保您在頁面加載中具有If語句,以僅在當前請求不是回發的情況下應用標簽文本,否則標簽將被設置為在每一個請求上。

If Not IsPostBack() Then
   lblSomeLabel.Text = "Page load text"
End If

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM