473,471 Members | 1,695 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Beginner problem with IF statements

Hi,

I'm just working on my first ASP.net site, and I'm having some problems.
In standard ASP I can easily display output based on whether any content
exists for the database field I'm displaying, but I can't seem to work
out how to do the same thing in ASP.net.

What I'm trying to do is display the content of a Dataset if it doesn't
match a particular value. I have a NavName Dataset, which contains the
name of the section of the site the user is in. If the name of the
section is Home, I don't want the name displayed. In classic ASP I'd
use:

<% if DSNavName.FieldValue("Navname") <> "home" then
response.write "<h1>"
response.write DSNavName.FieldValue("Navname")
response.write "</h1>"
end if %>

But if I try to use a varient on this I get an error message. Do I need
to put this into an "asp:" type block?

Sorry if this seems a really basic question!

Karen

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #1
1 992
This is where the bound controls actually start being really useful. There
are lots of ways to manage the data once you have it in a dataset.

This example show how to split the data based on a condition using something
called a Rowfilter.

http://authors.aspalliance.com/aldot...oublegrid.aspx

Also, using a template column in a bound control like a datagrid allows you
to pass each value through a method (a function) that returns a new or
modified value, thus the example above could be filtered further.

<itemtemplate>
<span><%#
myCustomMethod(Container.DataItem("PersonGender")) %></span>
</itemtemplate>

If you want to do it he old fashioned way, and format the output completely
on your own then you can iterate the dataset using foreach as shown in this
excellent example here

http://authors.aspalliance.com/aspxt....aspx?pageno=8
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"Karen" <an*******@devdex.com> wrote in message
news:OR*************@TK2MSFTNGP11.phx.gbl...
Hi,

I'm just working on my first ASP.net site, and I'm having some problems.
In standard ASP I can easily display output based on whether any content
exists for the database field I'm displaying, but I can't seem to work
out how to do the same thing in ASP.net.

What I'm trying to do is display the content of a Dataset if it doesn't
match a particular value. I have a NavName Dataset, which contains the
name of the section of the site the user is in. If the name of the
section is Home, I don't want the name displayed. In classic ASP I'd
use:

<% if DSNavName.FieldValue("Navname") <> "home" then
response.write "<h1>"
response.write DSNavName.FieldValue("Navname")
response.write "</h1>"
end if %>

But if I try to use a varient on this I get an error message. Do I need
to put this into an "asp:" type block?

Sorry if this seems a really basic question!

Karen

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: kackson | last post by:
Hi. What does it mean when it is written as: in the test.hpp file-> class MYFUNCTION: public TOP { public: ....some variables... MYFUNCTION(int x, int y, int z.. and some more argument);
8
by: Bshealey786 | last post by:
Okay im doing my final project for my first computer science class(its my major, so it will be my first of many), but anyway im a beginner so im not to great with C++ yet. Anyway this is the error...
12
by: Blaze | last post by:
I am doing the first walk through on the Visual Studio .Net walkthrough book to learn a little about programming. I am having issues with the first tutorial not running correctly. It seems that...
27
by: MHoffman | last post by:
I am just learning to program, and hoping someone can help me with the following: for a simple calculator, a string is entered into a text box ... how do I prevent the user from entering a text...
12
by: Joshua Rulz | last post by:
Hi, i want to learn to program im quite skilled with computers and want to learn c++. is there anyone who can teach me or tell me a good website to learn it? all replies will be appreciated.
3
by: Neal | last post by:
managed C++ VS 2003 I have a beginner question about windows forms.... I need to call a function when a certain limit has been reached, now with the way VS sets up the .NET windows Form I get...
10
by: R.A.M. | last post by:
Hello, I am trying to learn SQL Server. I need to write a trigger which deletes positions of the document depending on the movement type. Here's my code: set ANSI_NULLS ON set...
1
by: redpayne | last post by:
Ok-I am doing homework out of a book and the instructions are to display an interface with 5 option buttons in a frame. When clicked, each button changes the background color of the frame. It...
2
by: CC | last post by:
Hi: http://web.newsguy.com/crcarl/python/hexl.py This is my first Python program other than tutorial code snippet experimentation. I chose a hex line editor. I may do a hex screen editor...
2
by: malcster2 | last post by:
hello, i am a beginner to ajax. i have created a mysql database, which i would like to access from a web page. i have created 3 files, a html to display the data, a php file to extract the data,...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.