unable to find Dropdown list data

Posted by Swaroopa under C# on 6/29/2012 | Points: 10 | Views : 1522 | Status : [Member] | Replies : 4
Hi,

Based on session value finding dropdownlist data , getting error

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Swaroopa


Responses

Posted by: Jeffie on: 6/29/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Can you post the code implemented for this.
In order to catch the exception you can go a condition if session is not null

Thanks
http://www.alacraft.com.au/


Swaroopa, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 6/29/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Hi,

post your code.
check your session varriable. i think, it will throw null value.

Swaroopa, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Anu.Malik on: 7/4/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,

When we want to select any value in dropdown then it must be check first the value is exsits or not in dropdownlist.
And When we use any session variable first need to check session is not null or empty.
ex.

if (!(String.IsNullOrEmpty(Convert.ToString(Session["value"]))))
{
if (ddl.Items.FindByValue(Session["value"]) != null)
{
ddl.SelectedValue =Session["value"]) ;
}
}

Thanks & Regards ,
Anu Malik

Swaroopa, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Patel28rajendra on: 7/5/2012 [Member] Starter | Points: 25

Up
0
Down
Hi

I think your session value is null so that you are getting this error please first put condition for Session is null or not
Then set dropdown Selected Value


Thanks

R D Patel

Swaroopa, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response