简体   繁体   English

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

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

In my VB.net ASP application, i have some ASPTREEVIEW where, on page load there is a Label, to which i set some value. 在我的VB.net ASP应用程序中,我有一些ASPTREEVIEW,在页面加载时有一个Label,我为其设置了一些值。 After clicking on any row, i catch that value & assign it to the label. 单击任何行后,我捕获该值并将其分配给标签。

But suddenly that label value is not updating by the chosen value. 但是突然之间,标签值并没有根据所选值进行更新。 As if i check it via debugging the value, the value changes, but when i use Lable.text = chosen_value... It sets the value, but it is not actually changing on the html page. 好像我通过调试值进行检查一样,值也会更改,但是当我使用Lable.text = selected_value ...时,它会设置值,但实际上在html页面上并没有更改。 HTML shows the old value. HTML显示了旧值。

What will be the problem, i am not getting it. 会有什么问题,我没有得到。

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

Post some code so we can see exactly what your doing, without seeing anything so far ensure you have an If statement in your page load to only apply the label text if the current request is not a postback other wise the the label will be set to this on every request. 发布一些代码,以便我们可以准确地看到您所做的事情,到目前为止,什么都没有看到,请确保您在页面加载中具有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