473,387 Members | 1,520 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.

Converting to a variable

147 100+
Hi

I can't do this. I have spent over a week looking/reading books/internet and have got no where.

I would like to apply an if else statement to an <%# Eval

I would like to say:

<%#
if ((DataBinder.Eval(Container.DataItem, "Pn")) !="" )
{
string var_Pn = ((DataBinder.Eval(Container.DataItem, "Pn")).ToString())
response.write = "Find some thing else";
}

%>

I have posted similar before, but have gotten no where and am quite desperate for help.
Jun 6 '08 #1
6 1014
DaveRook
147 100+
Hi

I can't do this. I have spent over a week looking/reading books/internet and have got no where.

I would like to apply an if else statement to an <%# Eval

I would like to say:

Expand|Select|Wrap|Line Numbers
  1. <%#
  2. if ((DataBinder.Eval(Container.DataItem, "Pn")) !="" )
  3. {
  4.     string var_Pn = ((DataBinder.Eval(Container.DataItem, "Pn")).ToString())
  5.     response.write = "Find some thing else";
  6. }
  7. %>
I have posted similar before, but have gotten no where and am quite desperate for help.

Thanks

Dave
Jun 6 '08 #2
CyberSoftHari
487 Expert 256MB
You can use like
Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim myNum
  3. myNum = 6
  4. If myNum = 6 The
  5. {
  6.       //True part here
  7.       Response.Write("Variable myNum = 6")
  8. }
  9. else
  10. {
  11.        //False part here
  12.       Response.Write("Variable myNum = 6")
  13. }
  14. %>
Note: You cannot expect your reply within some time. consider time zones of different places and this is an international community.
Jun 6 '08 #3
Curtis Rutland
3,256 Expert 2GB
You can use like
Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim myNum
  3. myNum = 6
  4. If myNum = 6 The
  5. {
  6.       //True part here
  7.       Response.Write("Variable myNum = 6")
  8. }
  9. else
  10. {
  11.        //False part here
  12.       Response.Write("Variable myNum = 6")
  13. }
  14. %>
Note: You cannot expect your reply within some time. consider time zones of different places and this is an international community.
I don't think that this will work inside a Repeater or Datalist. He was using the <%# tags.

I'm not sure that this is possible. What I've done in the past is use a Literal control, and use my code behind to fill it with a for loop, and the results are just like a repeater.
Jun 6 '08 #4
CyberSoftHari
487 Expert 256MB
I am unable to understand his topic and the query asked inside (I am not in flow with previous OP’s post), better he should give appropriate topic.
Expand|Select|Wrap|Line Numbers
  1. <body>
  2.     <form id="form1" runat="server">
  3.         <asp:ScriptManager ID="ScriptManager1" runat="server" />
  4.         <div>
  5.             <asp:UpdatePanel ID="UpdatePanel1" runat="server">
  6.                 <ContentTemplate>
  7.                 <% for (int i = 0; i <= 3; i++)
  8.                    { %>
  9.                     <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
  10.                     <%
  11.                         if (TextBox1.Text == "")
  12.                         {
  13.                             TextBox1.Text = "MyName";
  14.                         }
  15.                         else
  16.                         {
  17.                             TextBox1.Text = "YourName";
  18.                         }
  19.                    } %>
  20.                 </ContentTemplate>
  21.             </asp:UpdatePanel>
  22.             &nbsp;</div>
  23.         <asp:Button ID="Button1" runat="server" Text="Button" />
  24.     </form>
  25. </body>
Above sample i tested and I never found any difficult or error to run. Thanks to make myself a conformation.

DaveRook, Give appropriate topic and explain your problem in detail. You have to check your code tags. starting with <%# and Closing with %>
Jun 6 '08 #5
Plater
7,872 Expert 4TB
Threads Merged. Please do not double post your questions, it is against the posting guidelines.

MODERATOR

What I've done in the past is use a Literal control, and use my code behind to fill it with a for loop, and the results are just like a repeater.
Yeah, I am a big fan of NOT doing anything inside <%# tags. Control code is for code files, designer code is for design files.
I recomend switching to using backend code to controls things, makes life easier when you need to manipulate the data. Divide and conquer and all that.
Jun 9 '08 #6
CyberSoftHari
487 Expert 256MB
I agree and never prefer <%{Code}%> this code tags inside Html, but it is hard to OP for recode everything in his project. So pointing that way will be simplest to him/her.
Jun 10 '08 #7

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

Similar topics

4
by: Joseph Suprenant | last post by:
I have an array of unsigned chars and i would like them converted to an array of ints. What is the best way to do this? Using RedHat 7.3 on an Intel Pentium 4 machine. Having trouble here, hope...
4
by: sal | last post by:
Greets, All Converting array formula to work with datatables/dataset tia sal I finally completed a formula I was working on, see working code below. I would like to change this code so it...
5
by: Testguy | last post by:
Hi, I was wondering if one the smart people that frequent this group could give me a hand with a small program I am attempting to debug. I am not a highly experienced developer, but can...
4
by: gg9h0st | last post by:
i'm a newbie studying php. i was into array part on tutorial and it says i'll get an array having keys that from member variable's name by converting an object to array. i guessed "i can...
0
by: anide | last post by:
Hi all I’ve some problem, I’m trying to converting a sorting algorithm from C++ to C#. In C++ I’ve compiled it using MSVC and its working properly, and in C# I’m using .NET Framework 2.0 (Visual...
10
by: Ron | last post by:
I want to calculate the surface area of a sphere from an inputed radius with option strict on. I guess I am not converting something correctly. Here is what I am doing: I have a textbox...
10
by: Karl Rhodes | last post by:
Hi all, I'm in the middle of converting some C# code to VB and I'm almost done, but this last little bit is confusing me. I'm trying to convert the following C# code... public event...
1
by: patrickdub | last post by:
Hi, I'm wondering what kind of things do I need to look out for when converting my .cmg scripts to Unix scripts. (I want the same inputs and outputs, but I'm now running on a Unix Server. I know...
35
by: Sean Farrow | last post by:
Hi: What is best and safest way of converting a char* to a const char *? Can I use const_cast? Cheers Sean.
1
by: Michelle Sollicito eBarster | last post by:
Ok I know a lot of asp but not a lot of asp.net and C# so please bear with me. I need some help converting.. In my asp project I have some styles in my head tag that change according to a...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
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.