473,473 Members | 4,208 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

String Formatting question

I have a string being returned to my in my ascx file. I get access to it like this... <%# DataBinder.Eval(Container.DataItem, "RoomNumber") %>. This is pretty simple. I want to be able to take the value of "RoomNumber" and do a substring on it. So if RoomNumber returns "A1234," I want to be able to get "A" or "4" from this return value. How can I do this in C# inline in my ascx?

I know I can use <%= %> and <%# %>, but I am not clear on which ones to use at which occassions. I think I would need something to return "RoomNumber" followed by a .Substring(1,1) or something. Can anyone suggest something?

Thanks,

Alex
Nov 18 '05 #1
1 967
Nevermind, I figured this out after I sent the question, of course. I solved it like this...

<%# DataBinder.Eval(Container.DataItem, "RoomNumber").ToString().Substring(1,3) %>

--
Alex
"Alex" <al**@nospam.net> wrote in message news:e7**************@TK2MSFTNGP12.phx.gbl...
I have a string being returned to my in my ascx file. I get access to it like this... <%# DataBinder.Eval(Container.DataItem, "RoomNumber") %>. This is pretty simple. I want to be able to take the value of "RoomNumber" and do a substring on it. So if RoomNumber returns "A1234," I want to be able to get "A" or "4" from this return value. How can I do this in C# inline in my ascx?

I know I can use <%= %> and <%# %>, but I am not clear on which ones to use at which occassions. I think I would need something to return "RoomNumber" followed by a .Substring(1,1) or something. Can anyone suggest something?

Thanks,

Alex
Nov 18 '05 #2

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

Similar topics

7
by: Roger Helliwell | last post by:
Hello Everyone, Has anyone found a quick reference for the many string formatting options for string.Format() ? I'm spending a ridiculous amount of time trying to write one line of code that...
5
by: Burak | last post by:
Hello, I would like to format the string "11304200" into "11-3042.00". Can I do this with String.Format method? I have not come across any good documentation. Thank you,
7
by: Steven D'Aprano | last post by:
I have a sinking feeling I'm missing something really, really simple. I'm looking for a format string similar to '%.3f' except that trailing zeroes are not included. To give some examples: ...
7
by: L. Scott M. | last post by:
Have a quick simple question: dim x as string x = "1234567890" ------------------------------------------------------- VB 6 dim y as string
11
by: Dustan | last post by:
Is there any builtin function or module with a function similar to my made-up, not-written deformat function as follows? I can't imagine it would be too easy to write, but possible... 'I am...
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...
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
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.