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 7029401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:32:04+00:00 2026-05-28T00:32:04+00:00

Basically in my in my aspx page I have a gridview which displays the

  • 0

Basically in my in my aspx page I have a gridview which displays the value from my database as an image. So if a value in my database table is 5, it will be displayed as 5 images in the gridview. ie.(star.jpg star.jpg star.jpg star.jpg star.jpg)

The code:

Protected Function getrating(ByVal rate As Integer)
        Dim getrating As String
        getrating = ""
        For i = 1 To rate
            getrating = getrating + "<img src=""Images/star.jpg"" alt=""*"">"
        Next
        Return getrating
    End Function

It’s been working fine so far for whole numbers, but now I’m adding averages into my database, so any value with a decimal point(like 4.6) gives me the error

"Conversion from type 'DBNull' to type 'Integer' is not valid."

How would I go about in adding images when the value has a decimal point?

Since the field in my database has the range set to numbers 1 to 5, I like it to display another image if the value has a decimal point. ie. “3.5” would display in the gridview star.jpg, star.jpg, star.jpg, halfstar.jpg. If that made any sense lol.

Anyone have an idea on how to do doing this?

  • 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-28T00:32:04+00:00Added an answer on May 28, 2026 at 12:32 am

    Judging by your error, it’s probable that you’re not even accepting decimal values and inserting the NULL value when they occur. Fix that first, make sure the result isn’t DBNull, then you can make the changes to a decimal type like Double:

    Protected Function GetRating(ByVal rating As Double) As String
        Dim result As New System.Text.StringBuilder()
    
        While rating >= 1.0#
            result.Append("<img src=""Images/star.jpg"" alt=""*"">")
            rating -= 1.0#
        End While
    
        If rating > 0.0# Then _
            result.Append("<img src=""Images/halfstar.jpg"" alt=""1/2"">")
    
        Return result.ToString()
    End Function
    

    I also took the liberty of using a StringBuilder instead of concatenating strings with +.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I have a gridview that I page through the server instead of in
I have an aspx web page (opener) which opens a popup window In the
I have an aspx page which shows preview of html-email. The html email comes
I have a Django website that basically just displays a bunch of items from
I have an aspx master/content page scenario. The parent page has an IFrame which
I have the following structure in an aspx page: <asp:Panel ID=pnlCust runat=server> <asp:GridView ID=gvMaster
This is what I'm talking about: http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ComboBox/ComboBox.aspx basically I want to have a drop
Basically I am trying to restart a service from a php web page. Here
In an ASP.NET MVC aspx page I have the following script: <script type=text/c# runat=server>
I have an aspx page that, on a button click, creates an instance of

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.