c# - Change gridview text to hyperlink -


i have gridview user contact information want include links online social media profiles email is, if gridview had name, role , contact contact row have user's email address , link social media account.

here code have far accomplish this, unsure of make text hyperlink on being databound

protected void contacts_onitemdatabound(object sender, griditemeventargs e)         {             var dataitem = e.item griddataitem;              if (dataitem != null && dataitem["contact"].text == "test@tester.com")              {                 dataitem["contact"].text = //where stopped because figured text hyperlink go here             }         } 

and here aspx code gridview, using telerik same idea:

     <telerik:radgrid id="contacts" runat="server">             <mastertableview autogeneratecolumns="false" bordercolor="white"                  headerstyle-font-bold="true" headerstyle-forecolor="white">                 <columns>                     <telerik:gridboundcolumn datafield="alternatecontact" filtercontrolalttext="filter alternatecontact column" headertext="alternate" sortexpression="alternatecontact" uniquename="alternatecontact"/>                                            <telerik:gridboundcolumn datafield="role" filtercontrolalttext="filter role column" headertext="role" sortexpression="role" uniquename="role"/>                                            <telerik:gridboundcolumn datafield="contact" filtercontrolalttext="filter contact column" headertext="contact" sortexpression="contact" uniquename="contact" />                                       </columns>             </mastertableview>             </telerik:radgrid> 

any advice on how accomplish helpful, thanks!

there 2 ways this. can either change gridboundcolumn gridhyperlinkcolumn, or can put html in gridboundcolumn

assuming bulk of function working properly, change this:

protected void contacts_onitemdatabound(object sender, griditemeventargs e)     {         var dataitem = e.item griddataitem;          if (dataitem != null && dataitem["contact"].text == "test@tester.com")          {             dataitem["contact"].text = string.format("<a href=\"mailto:{0}\">{1}</a>", emailaddress, emailaddress);         }     } 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -