Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 4th, 2003, 08:00 AM
Registered User
 
Join Date: Jun 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default ADO.NET Problem

I have a web-based form in ASP.NET that currently accesses a SQL 2000 database to show details of items. The items sometimes do not use all of the same columns though, and instead of listing the column data in an ASP.NET form with no data in a cell, I'd like to just skip displaying that cell in my page altogether. I have an ASP 3.0 version of this that works fine, but I can't get it working in ASP.NET. :( All I really need to know is how to do this in ASP.NET:

<%
If rsItems("ItemDescription") = "N/A" Then
Response.Write("")
Else
%>
<ENTER THE TABLE>
<% End If %>

If there isn't anything to display, I enter "N/A" in the database. Can anyone tell me how to just access the value of a single column in the current recordset to evaluate it as displayed above? The entire SQL statements are already configured and working fine, I just need this small addition.

Thanks!
 
Old June 5th, 2003, 05:01 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

It all depends on how you set up your data display.

One way to do this is to use the OnItemCreated event of a databound ASP.NET control like the Datagrid or the Repeater. Another way is to use simple databinding and bind to a function. Something like this:

<%# DataBinder.Eval(Container.DataItem, MyCustomFunction(Container.DataItem("MyColumn"))) %>

Your custom function (in code behind for example) could look like this:

Private Functon MyCustomFunction(ByVal ValueToCheck As String) As String
If ValueToCheck.Length = 0 Then
    Return ""
Else
    Return ValueToCheck
End If
End Function

Does this help? If not, could you please be more specific about the problem and your (partial) solution?

Cheers,

Imar





Similar Threads
Thread Thread Starter Forum Replies Last Post
ADO.Net Problem akhilesh_g ASP.NET 2.0 Professional 2 December 18th, 2007 05:33 AM
Ado.net Problem... NitinJoshi General .NET 2 January 10th, 2005 04:49 AM
how to deal with this problem related with ADO.NET zouky ADO.NET 2 October 8th, 2004 04:30 AM
'like' problem with asp.net/ ado badgolfer Access ASP 2 September 16th, 2004 01:50 PM
ADO.NET Problem lakmaldp ADO.NET 1 July 15th, 2004 01:58 AM





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