2014年7月13日 星期日

[RESOLVED] data format string for email and website in gridview ?


 I have 2 columns that has the datatype hyperlink, one is called email and the other one website.


when it shows up in the gridview, this is how it shows : contact@printing.com#mailto:contact@printing.com#


and the website shows up like this : www.rentacar.com#http://www.rentacar.com#


how do i make it show as a link in the gridview like mailto link and website link so that when i click on the respective links the programs could open, email:outlook and website:firefox


 Regards n thanks in advance.

 



Use a TemplateField instead of a BoundField :


<asp:TemplateField
HeaderText="Email"
ItemStyle-CssClass="Boolean">



<itemtemplate>



<a
href='mailto:<%# Eval("Email") %>'><%# Eval("Email") %>asp:Image>a>



itemtemplate>



asp:TemplateField>




 no mate, does not work. It gives me an error on 
asp:Image> "cannot switch view" and then when it runs it gives me a boundfield error. i think i
need to define a boundfield, cause u only defined a headertext="Email".


any way of doing this normally with what i have ? 


        AutoGenerateColumns="False" BorderColor="Black"
BorderWidth="1px" CellPadding="3" CellSpacing="1" DataKeyNames="ContactID" DataSourceID="AccessDataSource1"
Font-Names="Verdana" Font-Size="8pt" GridLines="None">



SortExpression="ContactTelephoneS" />
SortExpression="ContactTelephoneD" />















 

noworries, i found it and hope everyone having problems with showing mail links in gridview can use this :)



Hope this helps all :)


Thanks and regards .. 



Sorrry for necro posting but I think this way is a bit cleaner:











沒有留言:

張貼留言