hi,
I have a form which contains textboxes,"search" button.when user enter the values and click on the button I have to display the search details. and
I have to display no.of searchresults:
no.of search results i have obtained by using array.length; I want to use this value in another view page.so I put this value in the sessionStorage.setItem("getCount",len);
I am concatinating this value in the other view page like:
Search Results:" + sessionStorage.getItem('getCount') + "
I am getting the number of search results when user enters the value in the form.
but when user enter no values in the form then at the searchresults: it is displaying "null".but i want to display "0" insted of null.
how can i do this.
Loading
Jignesh TrivediPosted Aug 13, 2012, 8:48 AM
try...
int count = Session["getCount"] == null ? 0 : Convert.ToInt32(Session["getCount"]);
value of "count" assign to your textbox..
hope this will help you.
Vijay YadavPosted Aug 13, 2012, 7:12 AM
Nattudurai has suggested very well that you need to do. Or else you can simply put condition there, if null then concatenate zero or the value.
Nattudurai EswaramurthyPosted Aug 13, 2012, 6:47 AM
in the session its consider as object. so you need to convert it to the type which you want.
since ur not converting it to specific type, its displays "null".
In ur case, u need to convert it to Int, so u will get ur desired result
Hope this helpful to u.
Your Response is important to use. Please Check This is Currect Answer, if it helped