retrieving data from database and avoiding nulls

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neha90arora
    New Member
    • Mar 2013
    • 1

    retrieving data from database and avoiding nulls

    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...
  • prafullvyas272
    New Member
    • Mar 2013
    • 4

    #2
    you just put data type as float....
    i think through this your prob. can solve.
    just try it....

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      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

      Code:
      <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Int32>" %>
      <%
          string displayText;
      
          if (Model == 0)
          {
              displayText = "";
          }
          else
          {
              displayText = Model.ToString();
          }
      
      %>  
      
      <%= Html.TextBox("", displayText)%>

      Comment

      Working...