473,387 Members | 1,664 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

C# - <%# Eval...

147 100+
Hello

Is it possible to perform an if else statement and a loop on an Eval?

In asp.old I used to bring information via a database and if else it
eg,

Expand|Select|Wrap|Line Numbers
  1. <% if rsName.Fields.Item("columnName").Value <>"" then 
  2. response.write("string goes in here")
  3. end if%> 
Is it possible to do this in C#?

I will also need to assign the value to a variable.

eg, in asp.old

Expand|Select|Wrap|Line Numbers
  1. DIM var_ColumnContent = rsName.Fields.Item("columnName").Value
Any ideas?

Thank you
Jun 3 '08 #1
4 1479
Plater
7,872 Expert 4TB
All of that can be done pretty easily I would think.
Have you gone through any ASP.NET tutorials?
The "code-behind" or server side code is a good place for all of that.
Jun 3 '08 #2
DaveRook
147 100+
Hi Plater

Yes I have gone through several and have a few books. I can't seem to do it. It's quite possible I'm not searching for the correct thing! I will continue to look

Dave
Jun 4 '08 #3
Plater
7,872 Expert 4TB
Well for database work you will most likely have an instance of the DataTable object.
Now lets say I get results back from a database query with columns "Name" and "ID". And I want to look at the first results (0 index)

string s ="Hello "+ myDataTable.Rows[0]["Name"].ToString()+", nice to meet you.";

myDataTable.Rows[0]["Name"] is returned as an object instance. Since the column is string I could have done this:
string s ="Hello "+ ((string)myDataTable.Rows[0]["Name"])+", nice to meet you.";
And if I want the ID which is an int column:
int theID = (int)myDataTable.Rows[0]["ID"]

They symantics are a little different in VBNET, but you still have access to the same objects.
Jun 4 '08 #4
DaveRook
147 100+
Hi Plater

As always, thank you (and the website) for your help. Sadly, this didn't work, but I would not like any more help. I feel it is unfair to ask questions when quite clearly I need to improve on my own skills, so have purchased a few more books, one of which is training towards the MCTS.

Thank you again

Dave
Jun 5 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: CJM | last post by:
I've copied (& modified) some code from MSDN which uses a Repeater control, but I'm getting an error: Unexpected end of file looking for </HeaderTemplate> As far as I can see I've not made an...
4
by: Neil Zanella | last post by:
Hello, I would like to know what the difference is among the constructs <%= %> for evaluating an expression and displaying the evaluated result on the page and <%# %>. In particular I would like...
5
by: ad | last post by:
I find there are some tag like <%= %> and <%# > in my .aspx file. What is the diffreence between <%= %> and <%# %>
4
by: Satya | last post by:
Hi all, The following code is throwing a run time error "The server tag is not well formed. " <ItemTemplate> <asp:HyperLink Runat="server" ID="lnkFile"...
3
by: webserverpete | last post by:
I would like to have multiple <td> in a repeater control. The below code does not work: <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1" DataMember="DefaultView">...
3
by: | last post by:
I have been researching articles on google on how to create a simple RSS feed that sucks <title><blurb><link><date> out of a sql server 2000 database via an aspx page. I know it has to be pushed...
21
by: hemant.singh | last post by:
Hello all, I am try'g to send window.location.href to the server script who will generate dynamic javascript according to the referral name comg in as param Now bcz <script language="javascript"...
1
by: ruchirp | last post by:
Hi, I've been trying to overload << for a function similar to boost lambda library. I want to make for_each(v.begin(), b.end(), cout << _1 << endl); to work, however, i'm getting a lot of problems...
4
by: thaytu888888 | last post by:
Here is my codes in aspx page: <td colspan="2" class="main_menu" runat="server" onclick='toggleDisplay(<%#Eval("description")%>);'><%#Eval("description")%></td> Here is in "View source": ...
4
by: justice750 | last post by:
Hi All, I am using a FormView control. The allows me to update records in the database. However, when a database field is null I can not update the field on the form. It works fine when the field...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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
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...

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.