473,387 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Link Button question

I have a link button that i would like to be used if the value of the text is NOT 0...

So the code below will always make a linkbutton....

However if the value of "DataBinder.Eval(Container,"DataItem."+ JR.Core.Data.JobseekerData.FLD_SEARCH_MATCHES) " is 0 i do not want the the 0 to become a link.... I simply want to display it as text.

How can i do this?

<asp:LinkButton
CommandArgument='<%# DataBinder.Eval(Container,"DataItem."+ JR.Core.Data.JobseekerData.FLD_SEARCH_ID) +","+ DataBinder.Eval(Container,"DataItem."+ JR.Core.Data.JobseekerData.FLD_SEARCH_PROFILE_ID)% >'
CommandName='ProfileMatch'
id="ProfileMatch_Text" OnCommand="TextLinkClick" Runat=server CssClass="body_text">
<%# DataBinder.Eval(Container,"DataItem."+ JR.Core.Data.JobseekerData.FLD_SEARCH_MATCHES) %>
</asp:LinkButton>

Nov 18 '05 #1
2 1958
Darren,

Using the LinkButton, from my understanding will always give you a link regardless of what you give it. I had a DataGrid where I wanted somthing similar in a column, so I used a Label control in a templated column, and then created a function on the Code-Behind page that would receive the "DataBinder.Eval()" statement and return the full <A HREF> tag or a simple string depending on the data. But that sent the user off to another page, and if that is what you want, give it a try.

(I do VB.net)
Down and dirty example of what I did in the DataGrid:

Html side
<TemplateColumn>
blah blah blah
....
<asp:Label id="MyLabel" runat="server" Text='<%# ToLinkOrNot(DataBinder.Eval([data-item]) %>' />
</TemplateColumn>

Code-Behind
Private Function ToLinkOrNot(ByVal MyData As Object) As String
If CType(MyData, Double) = 0 Then
Return "Hello World!"
Else
Return "<A HREF=""mypage.aspx"">Hello World!</A>"
End If
End Function

But if you need the Link Button because you want to do a postback when a link is neeed, then you might try using both a regular Label Control and a Link Button side by side, and use a function on the code-behind page that would, based on the data you send it, populate and set Visible=True for the one you need.

Just a thought, hope it is in some way useful/helpful. :)

-- Andrew
"Darren Clark" <dc******@hotmail.com> wrote in message news:wt****************@news-server.bigpond.net.au...
I have a link button that i would like to be used if the value of the text is NOT 0...

So the code below will always make a linkbutton....

However if the value of "DataBinder.Eval(Container,"DataItem."+ JR.Core.Data.JobseekerData.FLD_SEARCH_MATCHES) " is 0 i do not want the the 0 to become a link.... I simply want to display it as text.

How can i do this?

<asp:LinkButton
CommandArgument='<%# DataBinder.Eval(Container,"DataItem."+ JR.Core.Data.JobseekerData.FLD_SEARCH_ID) +","+ DataBinder.Eval(Container,"DataItem."+ JR.Core.Data.JobseekerData.FLD_SEARCH_PROFILE_ID)% >'
CommandName='ProfileMatch'
id="ProfileMatch_Text" OnCommand="TextLinkClick" Runat=server CssClass="body_text">
<%# DataBinder.Eval(Container,"DataItem."+ JR.Core.Data.JobseekerData.FLD_SEARCH_MATCHES) %>
</asp:LinkButton>

Nov 18 '05 #2
Darren,

Using the LinkButton, from my understanding will always give you a link regardless of what you give it. I had a DataGrid where I wanted somthing similar in a column, so I used a Label control in a templated column, and then created a function on the Code-Behind page that would receive the "DataBinder.Eval()" statement and return the full <A HREF> tag or a simple string depending on the data. But that sent the user off to another page, and if that is what you want, give it a try.

(I do VB.net)
Down and dirty example of what I did in the DataGrid:

Html side
<TemplateColumn>
blah blah blah
....
<asp:Label id="MyLabel" runat="server" Text='<%# ToLinkOrNot(DataBinder.Eval([data-item]) %>' />
</TemplateColumn>

Code-Behind
Private Function ToLinkOrNot(ByVal MyData As Object) As String
If CType(MyData, Double) = 0 Then
Return "Hello World!"
Else
Return "<A HREF=""mypage.aspx"">Hello World!</A>"
End If
End Function

But if you need the Link Button because you want to do a postback when a link is neeed, then you might try using both a regular Label Control and a Link Button side by side, and use a function on the code-behind page that would, based on the data you send it, populate and set Visible=True for the one you need.

Just a thought, hope it is in some way useful/helpful. :)

-- Andrew
"Darren Clark" <dc******@hotmail.com> wrote in message news:wt****************@news-server.bigpond.net.au...
I have a link button that i would like to be used if the value of the text is NOT 0...

So the code below will always make a linkbutton....

However if the value of "DataBinder.Eval(Container,"DataItem."+ JR.Core.Data.JobseekerData.FLD_SEARCH_MATCHES) " is 0 i do not want the the 0 to become a link.... I simply want to display it as text.

How can i do this?

<asp:LinkButton
CommandArgument='<%# DataBinder.Eval(Container,"DataItem."+ JR.Core.Data.JobseekerData.FLD_SEARCH_ID) +","+ DataBinder.Eval(Container,"DataItem."+ JR.Core.Data.JobseekerData.FLD_SEARCH_PROFILE_ID)% >'
CommandName='ProfileMatch'
id="ProfileMatch_Text" OnCommand="TextLinkClick" Runat=server CssClass="body_text">
<%# DataBinder.Eval(Container,"DataItem."+ JR.Core.Data.JobseekerData.FLD_SEARCH_MATCHES) %>
</asp:LinkButton>

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: rachel | last post by:
Hi all, I am new in ASP.Net. I have a question on link multiple web forms together. Here is the scenario: I create an Index.aspx WebForm which consists of a banner and three navigator...
3
by: Chris Wilkinson | last post by:
Hi there, I'm creating a frames website, which consists of a nav bar down the left of the screen (name="frame1") and a content frame filling the right hand side (name="frame2"). I've used nice...
3
by: rachel | last post by:
Hi all, I am new in ASP.Net. I have a question on link multiple web forms together. Here is the scenario: I create an Index.aspx WebForm which consists of a banner and three navigator...
5
by: Amoril | last post by:
I've read quite a few different message on various boards and for some reason I'm still having trouble wrapping my head around this viewstate maintenance and trying to get these dynamically created...
6
by: liketofindoutwhy | last post by:
There is a link that encloses a span (or a div), but the link won't work in IE 7 (clicking on video image works, but not on the play button), while it works well in Firefox 2 and 3, and Safari 3....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.