Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Field in code?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Field in code?

 Post Reply Post Reply Page  12>
Author
Boecky View Drop Down
Groupie
Groupie
Avatar

Joined: 23 December 2002
Location: Belgium
Status: Offline
Points: 110
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boecky Quote  Post ReplyReply Direct Link To This Post Topic: Field in code?
    Posted: 13 January 2004 at 11:07am

Anybody knows how I can check in my code how I can see if a db query is empty?

something like

If Databinder.Eval(Container.DataItem, "Test") Is DBNull.Value Then

....

End If<%# binder.Eval(Container.Item, "er_nl") %><%# binder.Eval(Container.Item, "Title_nl") %><%# binder.Eval(Container.Item, "Title_nl") %>

Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 13 January 2004 at 11:09am
You can create sub's and functions and use them normally inside a <%# ... %>
e.g. <%# MyFunction(Databinder.Eval(Container.DataItem, "Test")) %>

Public Function MyFunction(data As object) As String
return "the data is " & data
End Function


Edited by Mart
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 13 January 2004 at 12:28pm

another angle:

to avoid having to seperately check for NULL or "emtpy string", i typically make sure the data coming back from the base is at least a  string, a la:

SELECT IsNull( SomeColumn, '' ) As SomeColumn FROM SomeTable

Contribute to the working anarchy we fondly call the Internet
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 13 January 2004 at 12:40pm
What will that return SomeColumn as? i.e. If its null does it return 0 and if not return 1?
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 13 January 2004 at 1:04pm
the sql statement i gave above will return "empty string" instead of NULL
Contribute to the working anarchy we fondly call the Internet
Back to Top
Boecky View Drop Down
Groupie
Groupie
Avatar

Joined: 23 December 2002
Location: Belgium
Status: Offline
Points: 110
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boecky Quote  Post ReplyReply Direct Link To This Post Posted: 14 January 2004 at 6:43am

I wanna hide a panel when the query is empty, and the repeater is in this panel...

Back to Top
Diep-Vriezer View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diep-Vriezer Quote  Post ReplyReply Direct Link To This Post Posted: 14 January 2004 at 11:16am

If QueryReturn = "emtry string" then

  yourPanel.visible = False

Else

  yourPanel.Visible = True

End If

Gone..
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 14 January 2004 at 11:20am

or in one line of code

yourPanel.Visible = (QueryReturn <> String.Empty)

Contribute to the working anarchy we fondly call the Internet
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.