We help IT Professionals succeed at work.
Get Started

remove comma from repeater when city is null

-Dman100-
-Dman100- asked
on
916 Views
Last Modified: 2012-05-09
I have a repeater that displays job postings by category, like the following:

Sales
 
Account Executive
 Austin, TX, US

The city field is not required and sometimes it is not input, so the display looks like this:

Sales
 
Account Executive
 , TX, US

It has the extra comma when the city is not entered and looks weird.

How can I remove that comma?

See below for the repeater code:


<asp:Repeater ID="Repeater2" runat="server">
                        <ItemTemplate>
                            <h4><%# Eval("CategoryName") %></h4>
                            <asp:Repeater ID="Repeater1" runat="server" DataSource='<%# GetJobsByCategory((int)(Eval("CategoryID"))) %>'>
                                <HeaderTemplate>
                                    <ul>
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <li><a href='<%# Eval("URL") %>' target="myIframe" onclick="javascript:document.location.href='#desc'"><%# Eval("JobTitle") %></a></li>
                                    <p style="text-indent:15px;font-size:small;"><%# Eval("City") %>, <%# Eval("State") %>, <%# Eval("Country") %></p>
                                </ItemTemplate>
                                <FooterTemplate>
                                    </ul>
                                </FooterTemplate>
                            </asp:Repeater>
                        </ItemTemplate>
                     </asp:Repeater>



code-behind:

private ADP.JobsDataTable allJobs = null;

protected void Page_Load(object sender, EventArgs e)
    {
        
        JobCategoriesBLL categoriesAPI = new JobCategoriesBLL();
        Repeater2.DataSource = categoriesAPI.GetCategories();
        Repeater2.DataBind();
    }

protected ADP.JobsDataTable GetJobsByCategory(int categoryID)
    {
        if (allJobs == null)
        {
            JobBLL jobsAPI = new JobBLL();

            return jobsAPI.GetJobsByCategory(categoryID);
        }

        allJobs.DefaultView.RowFilter = "CategoryID = " + categoryID;
        return allJobs;
    }

Open in new window

Comment
Watch Question
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE