473,405 Members | 2,373 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,405 software developers and data experts.

Dynamically enable or disable link buttons

I have link buttons in a Gridview that, depending on the value in another
column (Not the Key column) will need to be disabled.

For example, (Column2 has link buttons)

Column1 Column2
Books 54
Videos 6
Audio 3
I don't want Column2 to be clickable (i.e. "act like a link button) if
Column1's Value is "Audio"
I also have the need to disable Every single link button in the grid based
on another value on the page - but I'll be able to do that if I can figure
out how to do the first part.

How can I do this?
Jul 4 '08 #1
3 7903
the easiest way for me is to make a conditional on the onclick event, that
checks if column1 is clicked, then, exit sub...

or

in the rowcommand event:
dim col1 as checkbox = ctype(gridview.findcontrol(button1), checkbox)
dim col2 as button = ctype(gridview.findcontrol(button2), button)

if col1.checked=true then
col2.enable = false
else
col2.enable = true
end if
i think the might work..
[ ]'s
Christiano.


"Plateriot" <Pl*******@discussions.microsoft.comescreveu na mensagem
news:94**********************************@microsof t.com...
>I have link buttons in a Gridview that, depending on the value in another
column (Not the Key column) will need to be disabled.

For example, (Column2 has link buttons)

Column1 Column2
Books 54
Videos 6
Audio 3
I don't want Column2 to be clickable (i.e. "act like a link button) if
Column1's Value is "Audio"
I also have the need to disable Every single link button in the grid based
on another value on the page - but I'll be able to do that if I can
figure
out how to do the first part.

How can I do this?

Jul 4 '08 #2
Thank you. That did the trick.

"Christiano" wrote:
the easiest way for me is to make a conditional on the onclick event, that
checks if column1 is clicked, then, exit sub...

or

in the rowcommand event:
dim col1 as checkbox = ctype(gridview.findcontrol(button1), checkbox)
dim col2 as button = ctype(gridview.findcontrol(button2), button)

if col1.checked=true then
col2.enable = false
else
col2.enable = true
end if
i think the might work..
[ ]'s
Christiano.


"Plateriot" <Pl*******@discussions.microsoft.comescreveu na mensagem
news:94**********************************@microsof t.com...
I have link buttons in a Gridview that, depending on the value in another
column (Not the Key column) will need to be disabled.

For example, (Column2 has link buttons)

Column1 Column2
Books 54
Videos 6
Audio 3
I don't want Column2 to be clickable (i.e. "act like a link button) if
Column1's Value is "Audio"
I also have the need to disable Every single link button in the grid based
on another value on the page - but I'll be able to do that if I can
figure
out how to do the first part.

How can I do this?


Jul 4 '08 #3
I tried to add more conditions and it seems picky about them ---

For example, the first working thing I tried was to set the value I was
checking into a string variable -- that was strMeasure

I tried 2 others, (strTotLeft and strMissOpp) but it just seems to ignore
the code.
Here's my current complete code

If e.Row.RowType = DataControlRowType.DataRow Then
Dim MeasureTitle As TableCell = e.Row.Cells(0)
Dim MissOppVal As TableCell = e.Row.Cells(1)
Dim TotLeftVal As TableCell = e.Row.Cells(2)
Dim lnkTotalLeft As LinkButton =
CType(e.Row.Cells(2).Controls(0), LinkButton)
Dim lnkMissedOpp As LinkButton =
CType(e.Row.Cells(1).Controls(0), LinkButton)
Dim strMeasure As String
Dim strMissOpp As String
Dim strTotLeft As String
e.Row.Cells(7).Visible = False
strMeasure = MeasureTitle.Text
strMissOpp = MissOppVal.Text
strTotLeft = TotLeftVal.Text

'Any Aliased provider should be a disabled link
If Left(Me.cmbPCP.SelectedItem.Text, 2) = "ZZ" Then
lnkTotalLeft.Enabled = False
'link buttons should be disabled for certain measures
ElseIf strMeasure = "Percent of Care Gaps Closed" Then
lnkTotalLeft.Enabled = False
lnkMissedOpp.Enabled = False
'link buttons should be disabled if value is N/A
ElseIf strMissOpp = "N/A" Then
lnkMissedOpp.Enabled = False
ElseIf strTotLeft = "N/A" Then
lnkTotalLeft.Enabled = False
Else 'otherwise, link button can be enabled
lnkTotalLeft.Enabled = True
lnkMissedOpp.Enabled = True
End If

End If
Thank you for your suggestion - at least it got me moving.
"Christiano" wrote:
the easiest way for me is to make a conditional on the onclick event, that
checks if column1 is clicked, then, exit sub...

or

in the rowcommand event:
dim col1 as checkbox = ctype(gridview.findcontrol(button1), checkbox)
dim col2 as button = ctype(gridview.findcontrol(button2), button)

if col1.checked=true then
col2.enable = false
else
col2.enable = true
end if
i think the might work..
[ ]'s
Christiano.


"Plateriot" <Pl*******@discussions.microsoft.comescreveu na mensagem
news:94**********************************@microsof t.com...
I have link buttons in a Gridview that, depending on the value in another
column (Not the Key column) will need to be disabled.

For example, (Column2 has link buttons)

Column1 Column2
Books 54
Videos 6
Audio 3
I don't want Column2 to be clickable (i.e. "act like a link button) if
Column1's Value is "Audio"
I also have the need to disable Every single link button in the grid based
on another value on the page - but I'll be able to do that if I can
figure
out how to do the first part.

How can I do this?


Jul 4 '08 #4

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

Similar topics

32
by: Mark Johnson | last post by:
You have an, a, anchor with href link. Can you use a stylesheet to effectively disable the link, so that you can't click on it; that it will appear simply as text?
2
by: cotton_gear | last post by:
Hi, Depending on the user input I need to disbale/enable some of the links in my page. When disbled I need to display the links as normal text with cursor changed to mouse pointer style and when...
2
by: Dntc | last post by:
Hi All Is there anyway to enable/disable the toolbar buttons on the fly as like in MFC which helps centralizing this process?Let's i have a toolbar button ToolbarButtonSave which can be...
2
by: djc | last post by:
On the page_load event I am querying a database and binding data to some text boxes, list boxes, and a repeater control. When the page loads it uses the value of one of the database fields (status)...
1
by: inadsad | last post by:
Good Day, I have 2 forms with bindingNavigator and have a simple routine to enable/disable navigator buttons. Each nav button is assigned to a tag value. The problem is that if I want to...
6
by: Brandon McCombs | last post by:
Hello, I have a form that contains a listview on the left side and a column of buttons on the right side. Only some of the buttons do I want enabled all the time. The other buttons should be...
6
by: ree321 | last post by:
I have a linkbutton which is added to a column in a datagrid dynamically using a template I created. When I change the data in it by not databinding and then when I later retreive the data from the...
3
by: Pietro | last post by:
Hi all, First of all I'd like to thank you very very much ,as finally after many years of searching,I could find a code to disable/enable the shift key,but actually i cannot use the code as I'm...
1
by: hello2008 | last post by:
Hi, I have just started coding in PHP. I have coded a web page using HTML, JS, and PHP. An HTML table has to be populated dynamically using the data from the backend. Presently I have 5...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...

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.