hi
I used below code to save data in session:
UserData user = new UserData
{
Name = Txtname.Text,
State = DdlState.SelectedItem.Text,
City = DdlCity.SelectedItem.Text,
Mobile = TxtMob.Text,
Tell = txttell.Text,
Address = Txtaddu.Text,
PostCode = TxtcodeU.Text,
Email = TxtEmail.Text,
}
here in below line:
State = DdlState.SelectedItem.Text,
City = DdlCity.SelectedItem.Text,
save dropdownliast text in session
now I want State(session) in to dropdownlist:
if (Session["UserData"] != null)
{
UserData userData = Session["UserData"] as UserData;
if (userData != null)
{
Txtname.Text = userData.Name;
TxtMob.Text = userData.Mobile;
txttell.Text = userData.Tell;
TxtcodeU.Text = userData.PostCode;
DdlState.SelectedItem.Text = userData.State;
Txtaddu.Text = userData.Address;
TxtEmail.Text = userData.Email;
}
but this error happen:
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 58: txttell.Text = userData.Tell;
Line 59: TxtcodeU.Text = userData.PostCode;
Line 60: DdlState.SelectedItem.Text = userData.State;
Line 61: Txtaddu.Text = userData.Address;
Line 62: TxtEmail.Text = userData.Email;
|
Best Regards
Neda