Dynamically enable or disable link buttons

  • Thread starter Thread starter Plateriot
  • Start date Start date
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?
 
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.
 
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?
 
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?
 
Back
Top