ASP.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a ASP.NET Expert!

Join 308,429 ASP.NET Programmers for FREE! Get instant access to thousands of ASP.NET experts, tutorials, code snippets, and more! There are 3,250 people online right now. Registration is fast and FREE... Join Now!




Wrapping Around a Symbol

 

Wrapping Around a Symbol, Making a gridview column wrap around the @ symbol.

Mavirick

28 Jul, 2009 - 07:40 AM
Post #1

D.I.C Head
**

Joined: 18 Feb, 2008
Posts: 67



Thanked: 7 times
My Contributions
I have a search page that calls up information on a number of customers from a central database. One of the problems I've encountered is properly sizing the content page around the results, which are shown in a gridview with TemplateFields that are bound through code behind (rather than through the ASP).

Anyway, some of the customers work for companies with wacky email policies; for example, one company, whose name is already 12 letters long, further complicates their email domains by adding the location of the site, so you end up with something like firstname.lastname@aa.cityname.companyname.com. As you can imagine, this plays hell with my column sizing. To fix this, I've added a break-all attribute when the string is over a certain length:

CODE

protected void gridView_RowDataBound(object sender, GridViewRowEventArgs e)
{      
        System.Data.DataRowView drv;
        drv = (System.Data.DataRowView)e.Row.DataItem;
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string data = drv["user_email_address"].ToString();            
            if (data.Length > 25 && !data.Contains(" ")) //check email length and force wordbreak if length exceeds 25
                e.Row.Cells[4].Attributes.Add("style", "word-break:break-all;word-wrap:break-word");
        }
}


This works fine, but it ends up looking a bit sloppy. My question, then, is if there is any way I could force the email string to wrap around the @ symbol, so I have a nice two lines with the name on one line and the domain on the next:

firstname.lastname@
aa.cityname.companyname.com

Obviously I could just add a space after the @ symbol so that the browser did this itself, but these tables are often copied/pasted by users, so obviously we run into issues with pasting an email with a space after the @ symbol. Is there any other solution?

Thanks,
Mavirick

This post has been edited by Mavirick: 28 Jul, 2009 - 07:41 AM

User is offlineProfile CardPM
+Quote Post



Fast ReplyReply to this topicStart new topic

Time is now: 11/24/09 01:56PM

Live ASP.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

ASP.NET Tutorials

Reference Sheets

ASP.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month