Eval - DBNull - ObjectDataSource

A

Alexander Widera

Hello,

i'm using an asp:Reader and an ObjectDataSource. With this I get some
strings and integer-values... but some of the intergervalues could be a
<DBNull>-value.

In the repeater is a link, which should only be visible, if the an
integer-value isn't null (dbnull) (the value should be a number!).
I've tried much, but nothing worked. I get always an error-message with an
exception, that says, that the intergervalue is DBNull.

here is the code of the last try:

<asp:HyperLink ID="HyperLink2" runat="server" Visible='<%#
Eval("someID")!=DBNull.Value %>' NavigateUrl="#">My Link</asp:HyperLink>

I tried also:
((int?)Eval("someID")).HasValue

no success until now.


Could someone help me please?
thanks a lot,

Alex
 
K

Konstantinos Pantos

Have you tried
<asp:HyperLink ID="HyperLink2" runat="server" Visible='<%#
!Convert.IsDBNull(Eval("someID")) %>' NavigateUrl="#">My
Link</asp:HyperLink>?
 
A

Alexander Widera

doesn't work :(

the message again: The value for the row SomeID in table mytable is DBNull.
 
K

Konstantinos Pantos

Can you please provide some more info (exception info and/or code)?
It's really difficult to understand what's going on from a single line of
code.

____________________
Konstantinos Pantos
MCP Software Engineer
http://kostas.pantos.name
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top