We help IT Professionals succeed at work.
Get Started

Object cannot be cast from DBNull to other types

omegalove asked
Last Modified: 2012-05-09
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Object cannot be cast from DBNull to other types.

Source Error:

Line 155:                                                            <div class="details">
Line 156:                                                            <%# DataBinder.Eval(Container, "DataItem.img_is_primary") == System.DBNull.Value ? "" : (Convert.ToBoolean(DataBinder.Eval(Container, "DataItem.img_is_primary")) ? "Primary Picture" : "")%>
Line 157:                                                                <asp:LinkButton ID="lnkSetPrimary" CssClass="pagelink2" runat="server" OnClientClick="return confirm('Do you want to make this image your primary?');"
Line 158:                                                                    CommandArgument='<%#DataBinder.Eval(Container.DataItem, "img_id")%>' Visible='<%# !Convert.ToBoolean(DataBinder.Eval(Container, "DataItem.img_is_primary")) %>'
Line 159:                                                                    Text="Set Primary Photo" OnClick="SetPrimary"></asp:LinkButton><br />

Source File: c:\inetpub\wwwroot\OmegaLove.Web\OmegaLove.Web\Controls\ctrlUserProfilePics.ascx    Line: 157
Watch Question
This problem has been solved!
Unlock 3 Answers and 7 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE