Dynamically enable or disable link buttons

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?UGxhdGVyaW90?=

    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?
  • Christiano

    #2
    Re: Dynamically enable or disable link buttons

    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(but ton1), checkbox)
    dim col2 as button = ctype(gridview. findcontrol(but ton2), button)

    if col1.checked=tr ue then
    col2.enable = false
    else
    col2.enable = true
    end if


    i think the might work..


    [ ]'s
    Christiano.








    "Plateriot" <Plateriot@disc ussions.microso ft.comescreveu na mensagem
    news:94897F79-7A70-4A47-9025-90B462AF1970@mi crosoft.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?

    Comment

    • =?Utf-8?B?UGxhdGVyaW90?=

      #3
      Re: Dynamically enable or disable link buttons

      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(but ton1), checkbox)
      dim col2 as button = ctype(gridview. findcontrol(but ton2), button)
      >
      if col1.checked=tr ue then
      col2.enable = false
      else
      col2.enable = true
      end if
      >
      >
      i think the might work..
      >
      >
      [ ]'s
      Christiano.
      >
      >
      >
      >
      >
      >
      >
      >
      "Plateriot" <Plateriot@disc ussions.microso ft.comescreveu na mensagem
      news:94897F79-7A70-4A47-9025-90B462AF1970@mi crosoft.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?
      >
      >
      >

      Comment

      • =?Utf-8?B?UGxhdGVyaW90?=

        #4
        Re: Dynamically enable or disable link buttons

        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 = DataControlRowT ype.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.Cel ls(2).Controls( 0), LinkButton)
        Dim lnkMissedOpp As LinkButton =
        CType(e.Row.Cel ls(1).Controls( 0), LinkButton)
        Dim strMeasure As String
        Dim strMissOpp As String
        Dim strTotLeft As String


        e.Row.Cells(7). Visible = False
        strMeasure = MeasureTitle.Te xt
        strMissOpp = MissOppVal.Text
        strTotLeft = TotLeftVal.Text

        'Any Aliased provider should be a disabled link
        If Left(Me.cmbPCP. SelectedItem.Te xt, 2) = "ZZ" Then
        lnkTotalLeft.En abled = False
        'link buttons should be disabled for certain measures
        ElseIf strMeasure = "Percent of Care Gaps Closed" Then
        lnkTotalLeft.En abled = False
        lnkMissedOpp.En abled = False
        'link buttons should be disabled if value is N/A
        ElseIf strMissOpp = "N/A" Then
        lnkMissedOpp.En abled = False
        ElseIf strTotLeft = "N/A" Then
        lnkTotalLeft.En abled = False
        Else 'otherwise, link button can be enabled
        lnkTotalLeft.En abled = True
        lnkMissedOpp.En abled = 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(but ton1), checkbox)
        dim col2 as button = ctype(gridview. findcontrol(but ton2), button)
        >
        if col1.checked=tr ue then
        col2.enable = false
        else
        col2.enable = true
        end if
        >
        >
        i think the might work..
        >
        >
        [ ]'s
        Christiano.
        >
        >
        >
        >
        >
        >
        >
        >
        "Plateriot" <Plateriot@disc ussions.microso ft.comescreveu na mensagem
        news:94897F79-7A70-4A47-9025-90B462AF1970@mi crosoft.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?
        >
        >
        >

        Comment

        Working...