473,396 Members | 2,106 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,396 software developers and data experts.

ASP.NET and Customer HTML

Hello,

What is the proper way to implement the following:

1) We have a list of customers
2) Customers can have some optional fields. For example, second phone
number, comments, and others.
3) We need to display the customers in a list, but in a nicely formatted
way. In other words, if the customer has a second phone, we want to show it
nicely with the extension (if it has one), if there is no second phone, we
do not want to have to says: Phone 2 #: empty. Same goes for all the other
optional fields.

If we are using a Repeater, what is the right way to achive this? Should we
put the if-statements inside the <%# %> blocks in the .aspx file?

For example, should we do this:

<%#
if (DataBinder.Eval(Container.DataItem,"phone2") != "")
{
Response.Write("Phone 2#: " +
DataBinder.Eval(Container.DataItem,"phone2"));
if (DataBinder.Eval(Container.DataItem,"phone2ext") != "")

Response.Write("&nbsp;x-DataBinder.Eval(Container.DataItem,"phone2ext"));
}
%>

This seems too messy. Is this the right approach to handling custom html
inside repeaters?

Thanks,
Arsen
Nov 18 '05 #1
4 1086
The way I've done this, is to have a Label in the item template, and set its
Visible property to True or False depending on whether the field was null.
The text property would be bound either way - but if the label wasn't
visible, then it wouldn't matter.

This allows you to see at design time exacltly the layout, but at render
time, those customer's with the optional field filled in will have it
displayed, and those without it will not.

You can extend this to a Panel, with several web control inside it. You
could bind the controls, but set the Visible property on the Panel. So
either the whole thing is visible, or nothing is.

If you are going to use Response.Write's to achieve this, you might as well
be using ASP...

"Arsen Vladimirskiy" <ar***@emergency24.com> wrote in message
news:uQ**************@TK2MSFTNGP12.phx.gbl...
Hello,

What is the proper way to implement the following:

1) We have a list of customers
2) Customers can have some optional fields. For example, second phone
number, comments, and others.
3) We need to display the customers in a list, but in a nicely formatted
way. In other words, if the customer has a second phone, we want to show it nicely with the extension (if it has one), if there is no second phone, we
do not want to have to says: Phone 2 #: empty. Same goes for all the other
optional fields.

If we are using a Repeater, what is the right way to achive this? Should we put the if-statements inside the <%# %> blocks in the .aspx file?

For example, should we do this:

<%#
if (DataBinder.Eval(Container.DataItem,"phone2") != "")
{
Response.Write("Phone 2#: " +
DataBinder.Eval(Container.DataItem,"phone2"));
if (DataBinder.Eval(Container.DataItem,"phone2ext") != "")

Response.Write("&nbsp;x-DataBinder.Eval(Container.DataItem,"phone2ext"));
}
%>

This seems too messy. Is this the right approach to handling custom html
inside repeaters?

Thanks,
Arsen

Nov 18 '05 #2
Hi Marina,

Did you change the Visible property to False or True in the code-behind?

Did you write a function to handle the OnItemCreated event of the Repeater?

Thanks,
Arsen
"Marina" <nospam> wrote in message
news:OX**************@tk2msftngp13.phx.gbl...
The way I've done this, is to have a Label in the item template, and set its Visible property to True or False depending on whether the field was null.
The text property would be bound either way - but if the label wasn't
visible, then it wouldn't matter.

This allows you to see at design time exacltly the layout, but at render
time, those customer's with the optional field filled in will have it
displayed, and those without it will not.

You can extend this to a Panel, with several web control inside it. You
could bind the controls, but set the Visible property on the Panel. So
either the whole thing is visible, or nothing is.

If you are going to use Response.Write's to achieve this, you might as well be using ASP...

"Arsen Vladimirskiy" <ar***@emergency24.com> wrote in message
news:uQ**************@TK2MSFTNGP12.phx.gbl...
Hello,

What is the proper way to implement the following:

1) We have a list of customers
2) Customers can have some optional fields. For example, second phone
number, comments, and others.
3) We need to display the customers in a list, but in a nicely formatted
way. In other words, if the customer has a second phone, we want to show

it
nicely with the extension (if it has one), if there is no second phone, we do not want to have to says: Phone 2 #: empty. Same goes for all the other optional fields.

If we are using a Repeater, what is the right way to achive this? Should

we
put the if-statements inside the <%# %> blocks in the .aspx file?

For example, should we do this:

<%#
if (DataBinder.Eval(Container.DataItem,"phone2") != "")
{
Response.Write("Phone 2#: " +
DataBinder.Eval(Container.DataItem,"phone2"));
if (DataBinder.Eval(Container.DataItem,"phone2ext") != "")

Response.Write("&nbsp;x-DataBinder.Eval(Container.DataItem,"phone2ext")); }
%>

This seems too messy. Is this the right approach to handling custom html
inside repeaters?

Thanks,
Arsen


Nov 18 '05 #3
No, I did something like:

<asp:Label runat="server" Visible= '<%#
IIF(IsDBNull(Container.DataItem("MyCol")),False,Tr ue) %>' > <%#
Container.DataItem("MyCol") %> </asp:Label>

That's VB in the script, but easily changeable to C#.

"Arsen Vladimirskiy" <ar***@emergency24.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi Marina,

Did you change the Visible property to False or True in the code-behind?

Did you write a function to handle the OnItemCreated event of the Repeater?
Thanks,
Arsen
"Marina" <nospam> wrote in message
news:OX**************@tk2msftngp13.phx.gbl...
The way I've done this, is to have a Label in the item template, and set its
Visible property to True or False depending on whether the field was null.
The text property would be bound either way - but if the label wasn't
visible, then it wouldn't matter.

This allows you to see at design time exacltly the layout, but at render
time, those customer's with the optional field filled in will have it
displayed, and those without it will not.

You can extend this to a Panel, with several web control inside it. You
could bind the controls, but set the Visible property on the Panel. So
either the whole thing is visible, or nothing is.

If you are going to use Response.Write's to achieve this, you might as

well
be using ASP...

"Arsen Vladimirskiy" <ar***@emergency24.com> wrote in message
news:uQ**************@TK2MSFTNGP12.phx.gbl...
Hello,

What is the proper way to implement the following:

1) We have a list of customers
2) Customers can have some optional fields. For example, second phone
number, comments, and others.
3) We need to display the customers in a list, but in a nicely formatted way. In other words, if the customer has a second phone, we want to show
it
nicely with the extension (if it has one), if there is no second
phone, we do not want to have to says: Phone 2 #: empty. Same goes for all the other optional fields.

If we are using a Repeater, what is the right way to achive this?
Should we
put the if-statements inside the <%# %> blocks in the .aspx file?

For example, should we do this:

<%#
if (DataBinder.Eval(Container.DataItem,"phone2") != "")
{
Response.Write("Phone 2#: " +
DataBinder.Eval(Container.DataItem,"phone2"));
if (DataBinder.Eval(Container.DataItem,"phone2ext") != "")

Response.Write("&nbsp;x-DataBinder.Eval(Container.DataItem,"phone2ext")); }
%>

This seems too messy. Is this the right approach to handling custom

html inside repeaters?

Thanks,
Arsen



Nov 18 '05 #4
What is the equivalent of the IFF() command in C#?
Did you write the IFF() yourself?

"Marina" <nospam> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
No, I did something like:

<asp:Label runat="server" Visible= '<%#
IIF(IsDBNull(Container.DataItem("MyCol")),False,Tr ue) %>' > <%#
Container.DataItem("MyCol") %> </asp:Label>

That's VB in the script, but easily changeable to C#.

"Arsen Vladimirskiy" <ar***@emergency24.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi Marina,

Did you change the Visible property to False or True in the code-behind?

Did you write a function to handle the OnItemCreated event of the

Repeater?

Thanks,
Arsen
"Marina" <nospam> wrote in message
news:OX**************@tk2msftngp13.phx.gbl...
The way I've done this, is to have a Label in the item template, and set
its
Visible property to True or False depending on whether the field was null. The text property would be bound either way - but if the label wasn't
visible, then it wouldn't matter.

This allows you to see at design time exacltly the layout, but at
render time, those customer's with the optional field filled in will have it
displayed, and those without it will not.

You can extend this to a Panel, with several web control inside it. You could bind the controls, but set the Visible property on the Panel. So
either the whole thing is visible, or nothing is.

If you are going to use Response.Write's to achieve this, you might as

well
be using ASP...

"Arsen Vladimirskiy" <ar***@emergency24.com> wrote in message
news:uQ**************@TK2MSFTNGP12.phx.gbl...
> Hello,
>
> What is the proper way to implement the following:
>
> 1) We have a list of customers
> 2) Customers can have some optional fields. For example, second phone > number, comments, and others.
> 3) We need to display the customers in a list, but in a nicely

formatted > way. In other words, if the customer has a second phone, we want to show it
> nicely with the extension (if it has one), if there is no second phone,
we
> do not want to have to says: Phone 2 #: empty. Same goes for all the

other
> optional fields.
>
> If we are using a Repeater, what is the right way to achive this?

Should we
> put the if-statements inside the <%# %> blocks in the .aspx file?
>
> For example, should we do this:
>
> <%#
> if (DataBinder.Eval(Container.DataItem,"phone2") != "")
> {
> Response.Write("Phone 2#: " +
> DataBinder.Eval(Container.DataItem,"phone2"));
> if (DataBinder.Eval(Container.DataItem,"phone2ext") != "")
>
>

Response.Write("&nbsp;x-DataBinder.Eval(Container.DataItem,"phone2ext"));
> }
> %>
>
> This seems too messy. Is this the right approach to handling custom html > inside repeaters?
>
> Thanks,
> Arsen
>
>



Nov 18 '05 #5

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

Similar topics

14
by: Zac Hester | last post by:
I figured since a lot of us around here design sites for "customers" a lot, I'd ask a general question that might help a lot of us in the future. When dealing with clients asking for...
7
by: Zac Hester | last post by:
I figured since a lot of us around here design sites for "customers" a lot, I'd ask a general question that might help a lot of us in the future. When dealing with clients asking for...
1
by: Herman Beeksma | last post by:
Hi there! I have two tables: Customer (ID, Name) Invoice (ID, Date, Customer, Amount) and want to select only the *last* invoice for each customer. It's easy to get each customer's last...
2
by: nja2222 | last post by:
I would like to create a page for my clients to login and check for updates on their accounts. Then I would like to create a page where my employees can login and make updates, specifically new file...
1
by: ramprakashjava | last post by:
hi , i hav this error while running this customerDetails.jsp <html:html> <head> <html:base/> </head> <body> <html:errors/> <html:form...
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
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.