• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1580
  • Last Modified:

Insert Session value into formview textbox (asp.net vb)

Hi

I've got a session set called 'Selected date' which I'm trying to add to a textbox in a formview insertitem template.

How do i doi this?

My feeble attemt is

Dim Date2TextBox As TextBox

        FormView1.FindControl("Date2TextBox") = Session("Selecteddate")

 Also if the session is not present then i want the textbox to remain blank and not throw an error.

0
Ed
Asked:
Ed
1 Solution
 
techExtremeCommented:
Hi, what you are doing is ok, you just need to add logic to skip assigning value if session is nothing (for vb.net  or null for c#).

Use this code for it:

I'm using notepad to write this, so please check using intellisense that it is error free.

Dim tbx As TextBox = CType(FormView1.FindControl("Date2TextBox"), TextBox)

If Not Session("Selecteddate") is Nothing then

    tbx.text = Session("Selecteddate")
Else
    tbx.text = ""
end if
0
 
EdAuthor Commented:
Works perfectly, thnaks.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now