468,761 Members | 1,812 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,761 developers. It's quick & easy.

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 7519
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

32 posts views Thread by Mark Johnson | last post: by
1 post views Thread by inadsad | last post: by
6 posts views Thread by Brandon McCombs | last post: by
6 posts views Thread by ree321 | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.