473,480 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1965
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
3573
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
3557
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
335
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
6741
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
4462
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
7037
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
6904
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7034
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,...
1
6732
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5324
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4768
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4472
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2990
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
558
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.