Click here to Skip to main content
16,019,514 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i m passing three values like employeecode,month and year in session.And also catch the value of three variable in another page.but when i m assigning these values to three different dropdownlist like drpempcode,drpmonth,drpyear a error occures "an object reference not set to instance of an object".
please help me.....to solve this.....
Posted
Comments
Richard MacCutchan 25-Aug-12 4:31am    
Use your debugger to find out which object you are trying to use without initialising it.
SinghPrateek 25-Aug-12 6:13am    
Are you getting the error on session on dropdownlist object?
Share code, than we could help in finding the cause

Use Query strings to pass value from one page to another.And you can access the values from the query string.

Send the required value to the target page(Let it be Default2.aspx) like this
C#
Response.Redirect("Default2.aspx?pid=" +txtData.Text);


You can access the values at the target page(Default2.aspx).
eg:
C#
string projectid = Request.QueryString["pid"];


You can send multiple values throug query string like this using '?' and '&'
C#
Response.Redirect("Default2.aspx?pid=" +txtData.Text + "&fid=" + txtcountry.Text);


and access the values in same way.
C#
string projectid = Request.QueryString["pid"];
string FeatureId= Request.QueryString["fid"];
 
Share this answer
 
You need to post code if you want us to fix it. If you have three values that are related, create a class and store it in the session. If you pull values out of the session, always check if they are null first. A good trick is to create a static class like

static class SessionStrings
{
public static string UserId = "UserId";
}

Now when you access the session, do:

string s = Session[SessionStrings.UserId] as string;

Now you can't make typos.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900