Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 28th, 2006, 10:21 AM
Registered User
Points: 16, Level: 1
Points: 16, Level: 1 Points: 16, Level: 1 Points: 16, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2006
Location: san francisco, ca, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default IF recordset value =something then HIDE?

Hello all,

I have a tricky question that I just can't seem to figure out.

I have a list with two columns in it. str_thumb and reviews. its basicaly a list of reviews with a photo, and sometimes I don't have a photo, so the default value of a review without a photo is "none.jpg"

I would like to loop through the list and when a record with a value of "none.jpg" is pulled, it would hide it that image or lack of an image :-)

here is the code i'm tring to execute but it throws an error.

thanks for your help.

Wayne

<ASP:Repeater runat="server" DataSource='<%# RS.DefaultView %>'>
    <ItemTemplate>
<%
DIM strIMAGE
strIMAGE= RS.FieldValue("str_thumb", Container)
IF strIMAGE <>"NONE.jpg" then %>

<%# RS.FieldValue("str_thumb", Container) %>
<% end if %>



    </ItemTemplate>
</ASP:Repeater>

------------

the error

Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30451: Name 'Container' is not declared.

Source Error:

Line 26: DIM strIMAGE
Line 27:
Line 28: strIMAGE= RS.FieldValue("str_thumb", Container)
Line 29: IF strIMAGE <>"NONE.jpg" then %>
Line 30:


Source File: C:\Inetpub\wwwroot\sfsurvey2\dotnet\rsVB.aspx Line: 28

  #2 (permalink)  
Old October 28th, 2006, 02:37 PM
Registered User
Points: 16, Level: 1
Points: 16, Level: 1 Points: 16, Level: 1 Points: 16, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2006
Location: san francisco, ca, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I was able to do it by hand codeing, but would love to do it in visualstudio with some of the user controls.

<%@ Page Language="VB" Debug="true" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ OutputCache Duration="300" VaryByParam="*" %>
<%

Dim conSFMAN As SqlConnection
Dim cmdSelectRatings As SqlCommand
Dim dtrRatings As SqlDataReader
conSFMAN = New SqlConnection( "Server=DELL\SQLEXPRESS;uid=t;pwd=t;database=sfman " )
conSFMAN.Open()
cmdSelectRatings = New SqlCommand( "SELECT top 10 * FROM dbo.VIEW_ratings", conSFMAN )

dtrRatings = cmdSelectRatings.ExecuteReader()

While dtrRatings.Read() %>



    <% IF dtrRatings( "str_thumb" )<>"none.jpg" then%>
    <img src="../ad_images/<%=dtrRatings( "str_thumb" ) %>">
    <%else%>
    <b><h1>NO IMAGE to Display</h1></b>
    <% end if %>

<%=dtrRatings( "txt_description" ) %>
<%
End While

dtrRatings.Close()
conSFMAN.Close()


  #3 (permalink)  
Old October 29th, 2006, 10:00 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I would actuall do this in SQL:

SELECT
   ISNULL(imagepath, './director/noimage.jpg') as imagepath
From
   Table

This way there is no need to loop at all, your datasource will already have the correct path to the image or, in this case, the lack thereof an image.

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
  #4 (permalink)  
Old October 29th, 2006, 12:38 PM
Registered User
Points: 16, Level: 1
Points: 16, Level: 1 Points: 16, Level: 1 Points: 16, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2006
Location: san francisco, ca, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Dparsons,

Thanks for your reply.

In reading your reply I have noticed that my original statement was not clear.

The records that have a value of “none.jpg” also have data that I need to display, so filtering based on if they have an image or not is not a solution. I’ll always need to display the text associating the record, but some recods have images and some don’t. Either way I need to show all records and some of those records have images, which I’ll need to display.

thanks for your consideration.


  #5 (permalink)  
Old October 29th, 2006, 01:15 PM
Friend of Wrox
Points: 793, Level: 10
Points: 793, Level: 10 Points: 793, Level: 10 Points: 793, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2005
Location: OKC, OK, USA.
Posts: 227
Thanks: 1
Thanked 7 Times in 7 Posts
Default

waynelambright:
In your topic it was not clear that you wanted to print the review whether the review had a image or not, however my suggestion would be to give "none.jpg" some "none image", as a place holder or filler and continue to loop thru "read a record/row, write a record/row".

This is just a suggestion.
  #6 (permalink)  
Old October 30th, 2006, 01:53 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Thats fine, all the ISNULL fuction will do is that if there is no image path for the image it will display a default iamge (or whatever it is you need to display); you cna still grab the other fields from the row and display the corrosponding data just with a default image.

Had my statement been something like:

SELECT [columns] FROM [table] WHERE image is null (or where there is an image link) image is not null

then that would be a filter, the isnull in my previous example has nothing to do with filtering your results.

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Clone DAO Recordset into ADO Recordset kamrans74 VB How-To 0 March 6th, 2007 11:57 AM
Query from Recordset into another Recordset kamrans74 Pro VB Databases 5 March 5th, 2007 04:17 PM
ADODB.Recordset (0x800A0CB3)Current Recordset does tks_muthu Classic ASP Databases 0 June 16th, 2005 07:22 AM
Convert ADO recordset to DAO recordset andrew_taft Access 1 May 5th, 2004 02:31 PM



All times are GMT -4. The time now is 09:01 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.