Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 948733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:17:27+00:00 2026-05-15T23:17:27+00:00

I have many TextBOX in asp.net which accepts the value from user and stores

  • 0

I have many TextBOX in asp.net which accepts the value from user and stores it to SQL DB through SQL SERVER..
When the user does not enter the value in the textbox, Which means i can allow the null for that filed in the table, But if its integer variable it stores 0, thats because

int HostelFees ;
HostelFees = TextBox1.Text;
//function called to store the hostel fee
insertFee(hostelFees);

in Database it stores 0, which i dont want but it to be null..
I went through many documentations and understood only slightly about ISDBNULL, But still am confused regarding while inserting how i will insert null. 🙁 and i am not using any stored procedure’s.. infact in the function insertFee(hostelFees) i just use command.ExecuteNonQuery to insert it

Please can anyone give me proper explation or link which i refer.
Thank you,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T23:17:28+00:00Added an answer on May 15, 2026 at 11:17 pm

    You should consider using int?, which is a nullable version of int. In that case, you can use the HostelFees.HasValue check to see if a null is stored, and HostelFees.Value to use the integer part.

    Please note that in your sample you are directly storing a string value into an integer variable. That won’t work. What you want is to parse it first, then store null if it’s not an integer. Something like this:

    int? HostelFees = null;
    int parsedValue;
    
    if (int.TryParse(TextBox1.Text, out parsedValue)) {
        HostelFees = parsedValue;
    }
    
    //function called to store the hostel fee
    insertFee(hostelFees);
    

    And instead of assigning the integer value directly to the DbParameter, you can use the following construction:

    parameter.Value = (HostelFees.HasValue ? HostelFees.Value : DbNull.Value);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ASP.NET web page that contains many textboxes. Each textbox has a
I wanna diplay a Stopwatch timer... using Asp.Net C#... I have looked through many
I have for example ASP.NET site with textbox, button and many other controls. When
I have asp.net site. On many pages is used datetime to be putted from
I have a stored procedure which uses the IN clause. In my ASP.NET application,
I have two textbox in a page each uses ASP.Net Ajax Autocompleteextender control. asp:TextBox
I have an ASP.NET c# web application published to a server of ours. It
I am confused about something really simple in ASP.NET. I have seen many times
I have an ASP.Net MVC application with a model which is several layers deep
I have an ASP.NET user control that contains a text box control and a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.