473,802 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
+ 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.Field Value("Navname" ) <> "home" then
response.write "<h1>"
response.write DSNavName.Field Value("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 1012
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.DataI tem("PersonGend er")) %></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*******@devd ex.com> wrote in message
news:OR******** *****@TK2MSFTNG P11.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.Field Value("Navname" ) <> "home" then
response.write "<h1>"
response.write DSNavName.Field Value("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
1684
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
2012
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 msg that im getting: "Error executing cl.exe" this is the code that I have, but I know whats causing it, ill just show you the whole thing first though //file: Quadratic
12
1891
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 the build fails with what the book tells me to do. Specifically, I am doing this: public authors1 GetAuthors() { authors1 authors = new Authors1();
27
4377
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 instead of a number, or give an error message? Also, how can I make the program verify there are two valid entries in txtBox1 and txtBox2 to then ENABLE the button operators (ie +, -, /, *).
12
2121
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
2647
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 confused. When I was using Directx everything was being run from a while loop, so that was no problem for me in seeing where to place conditional statements and other functions. With windows forms do I need to have an event and eventhandler? it...
10
3020
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 QUOTED_IDENTIFIER ON go CREATE TRIGGER
1
2456
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 proceeds to tell me to construct CheckboxGroup, use FlowLayaout and add the Checkboxes to the frame along with ItemListener. It says addWindowListener()method, write code for itemStateChanged() which uses the getState() method and nested if statements....
2
3455
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 once this is done, if I feel like playing with the curses module. Or move straight to wxPython. This is unfinished, and is really just a hex viewer at this point. It
2
2262
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, and a javascript file to to the clever stuff. when i access the html page, all the data is displayed correcty, but if i add or delete any records, and press the button i have created to refresh the data(without reloading), the data doesn't change....
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10304
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10285
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7598
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5494
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.