A
Arsen Vladimirskiy
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(" x-DataBinder.Eval(Container.DataItem,"phone2ext"));
}
%>
This seems too messy. Is this the right approach to handling custom html
inside repeaters?
Thanks,
Arsen
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(" x-DataBinder.Eval(Container.DataItem,"phone2ext"));
}
%>
This seems too messy. Is this the right approach to handling custom html
inside repeaters?
Thanks,
Arsen