asp.net - c# how to set the styling of a gridview text field to 2 options: with hyperlink and without -


i have code gridview feild displays title, , evaluates hyperlink (link) in way if there value in link, title clickable , title redirect link.. followed:

<asp:templatefield headertext="title" sortexpression="title" controlstyle-forecolor="black">                 <itemtemplate >                    <asp:hyperlink id="title"  runat="server" text='<%# bind("title") %>'  navigateurl='<%# eval("link") %>' ></asp:hyperlink>                 </itemtemplate>             </asp:templatefield> 

the code working fine, title black. need style title in way if there link, blue , undelined, else black.

i'm using c#/aspx in here.

any idea?

try this

<asp:hyperlink id="title"  runat="server" text='<%# bind("title") %>'  navigateurl='<%# eval("link") %>' style='<%# eval("link").tostring()!=""? "text-decoration:underline;color:blue;":""%>'></asp:hyperlink> 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -