Dynamically enable or disable link buttons

P

Plateriot

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?
 
C

Christiano

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.
 
P

Plateriot

Thank you. That did the trick.

Christiano said:
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 said:
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?
 
P

Plateriot

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 said:
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 said:
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,809
Latest member
moe77

Latest Threads

Top