By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,162 Members | 1,038 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,162 IT Pros & Developers. It's quick & easy.

retrieving data from database and avoiding nulls

P: 1
hii all.....i have a small problem,act i am trying to retrieve my stored data from database it is retrieving the data properly but the problem is it is showing 0 value for the numeric textboxes which i left empty whlie saving the data.....this is rilly a problem........kindly help...
Mar 26 '13 #1
Share this Question
Share on Google+
2 Replies


P: 4
you just put data type as float....
i think through this your prob. can solve.
just try it....
Mar 26 '13 #2

10K+
P: 13,264
You could do a manual check that says if it's zero set the display check to "" but the cleaner approach would be to override the default templates this tutorial explains all about them :http://bradwilson.typepad.com/blog/2...templates.html

Your override would be something like

Expand|Select|Wrap|Line Numbers
  1. <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Int32>" %>
  2. <%
  3.     string displayText;
  4.  
  5.     if (Model == 0)
  6.     {
  7.         displayText = "";
  8.     }
  9.     else
  10.     {
  11.         displayText = Model.ToString();
  12.     }
  13.  
  14. %>  
  15.  
  16. <%= Html.TextBox("", displayText)%>
  17.  
  18.  
Mar 26 '13 #3

Post your reply

Sign in to post your reply or Sign up for a free account.