Forums » .NET » ASP.NET »

Datagrid Null Value Issue


Posted Date: 22 Jul 2012      Posted By:: Shivprasad H     Member Level: Bronze    Member Rank: 2324     Points: 1   Responses: 4



When I read a value from datagrid column and if it is null then the value is "&nsbp;"

I want it to be an empty string.

How to get this?




Responses

#681339    Author: Ravindran        Member Level: Diamond      Member Rank: 3     Date: 22/Jul/2012   Rating: 2 out of 52 out of 5     Points: 3

Hi,

Write one common methiod to check cells null value and before assign any variable pass that grid view cell text in to that method to make it empty instead of   like below code


string RetVal(string s)
{
string retval = "";
if (s == " ")
{
return retval;
}
else
{
return s.Trim();
}
}


and use like below line

string empname = RetVal(GridView1.Rows[0].Cells[1].Text);


Regards
N.Ravindran
Your Hard work never fails



 
#681340    Author: Prachi Kulkarni        Member Level: Gold      Member Rank: 25     Date: 22/Jul/2012   Rating: 2 out of 52 out of 5     Points: 2

Hi,
Regular expression to check empty string is as follows
^$|pattern
where ^$ is beginning and end of the string. | is used to denote alternates.
I hope it will be useful for you.

Regards,
Prachi Kulkarni.



 
#681350    Author: Shivprasad H      Member Level: Bronze      Member Rank: 2324     Date: 22/Jul/2012   Rating: 2 out of 52 out of 5     Points: 1

Thanks Ravindran currently am using the same method. But I felt there could be some other better method which I am not aware of.





 
#681351    Author: Shivprasad H      Member Level: Bronze      Member Rank: 2324     Date: 22/Jul/2012   Rating: 2 out of 52 out of 5     Points: 1

Thanks Prachi... But am not getting how to use it in code. Could you guide me in this?


 
Post Reply
You must Sign In to post a response.

Next : Which is the best one back end for asp.net
Previous : F12 is not opening the script window in Internet Explorer
Return to Discussion Forum
Post New Message
Category:

Related Messages
Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
2005 - 2012 All Rights Reserved.
.NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
Articles, tutorials and all other content offered here is for educational purpose only.
We are not associated with Microsoft or its partners.