hello.
i need help with this coding, i need to bring the temporary parameter from set page (which is user input) to the retrieve page in order to trigger the color. seems like the
session didn't carry the temporary value.

code in page set session;

Protected Sub ViewPara_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ViewPara.Click

        If HiddenAid.Value = "DSO" Then

            Session("tempara") = "true"
            Session("tempara1") = TextPara1.Text
            Session("tempara2") = TextPara2.Text
            Session("tempara3") = TextPara3.Text
            Session("temrange1") = TextRange1.Text
            Session("temrange2") = TextRange2.Text
            Session("temrange3") = TextRange3.Text
            Session("temrange4") = TextRange4.Text
            Response.Redirect("../Alert/DSO.aspx", False)

        End If

End Sub

code in page retrieve session;

Protected Sub repeaterAlert_ItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs) Handles repeaterAlert.ItemDataBound

       

        stockCodeheader.Text = " Stock Code "
        plcNameheader.Text = " PLC Name "
        boardheader.Text = " Board "
        sectorheader.Text = " Sector "
        subSectorheader.Text = " Sub Sector "
        yearheader.Text = " Year "
        total.Text = " DSO "

        Dim stockCode As Label = CType(e.Item.FindControl("stockCode"), Label)
        If Not IsNothing(stockCode) Then
            stockCode.Text = e.Item.DataItem("stock_code").ToString
        End If

        Dim plcName As Label = CType(e.Item.FindControl("plcName"), Label)
        If Not IsNothing(plcName) Then
            plcName.Text = e.Item.DataItem("current_name").ToString
        Else
        End If

        Dim board As Label = CType(e.Item.FindControl("board"), Label)
        If Not IsNothing(board) Then
            board.Text = e.Item.DataItem("board_name").ToString
        Else
        End If

        Dim sector As Label = CType(e.Item.FindControl("sector"), Label)
        If Not IsNothing(sector) Then
            sector.Text = e.Item.DataItem("sector_name").ToString
        Else
        End If

        Dim subSector As Label = CType(e.Item.FindControl("subSector"), Label)
        If Not IsNothing(subSector) Then
            subSector.Text = e.Item.DataItem("sub_sector_name").ToString
        Else
        End If

        Dim year As Label = CType(e.Item.FindControl("year"), Label)
        If Not IsNothing(year) Then
            year.Text = e.Item.DataItem("year_id").ToString
        Else
        End If

        Dim total1 As Label = CType(e.Item.FindControl("total1"), Label)
        total1.Text = e.Item.DataItem("dso").ToString
        Dim compval As Double = total1.Text
        total1.Text = Math.Round(compval, 2)

 '** alert's colour trigger **'

        Dim temporary As Double
        temporary = Session("tempara1").GetHashCode

        If Session("tempara") = "true" Then
            If total1.Text >= e.Item.DataItem(temporary).ToString Then
                total1.BackColor = Drawing.Color.Red
            End If
            If total1.Text >= e.Item.DataItem("para1").GetHashCode Then
                total1.BackColor = Drawing.Color.Red
            End If
        End If

    End Sub

Recommended Answers

All 6 Replies

use

Session.Add("tempara1",TextPara1.Text)

at the retrieve page or set page?

set page. At the retrieve page you should delete those session variables again with session.remove("tempara1"). Of course after you h ave everything you need.

when i write the code below, all the data that should be out didn't come out.
is there any problem with the code.

Dim temporary As Double
        temporary = Session("tempara1").GetHashCode
 
        If Session("tempara") = "true" Then
            If total1.Text >= e.Item.DataItem(temporary).GetHashCode Then
                total1.BackColor = Drawing.Color.Red
            End If
            If total1.Text >= e.Item.DataItem("para1").ToString Then
                total1.BackColor = Drawing.Color.Red
            End If
        End If
'Add session variable		
		Session.Add("tempara", True)
		'Check if true
		If CBool(Session("tempara")) Then
			'do what you want
			Debug.WriteLine("TRUE")
		End If
		'delete variable
		Session.Remove("tempara")

Because of the session the data that should be out didn't appear. where is it the error actually?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.