Access Control in ItemTemplate

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jonathan Wood

    Access Control in ItemTemplate

    I have a GridView control with one column a TemplateField that contains two
    buttons. I'd like to hide one or both button based on the row number.

    Can anyone provide some tips on how I can do this?

    Thanks.

    --
    Jonathan Wood
    SoftCircuits Programming


  • Eliyahu Goldin

    #2
    Re: Access Control in ItemTemplate

    Handle PreRender event for the gridview. In the event loop through the Rows
    collection. For every row use Cells collection to locate the column. Once on
    the column, use FindControl method to locate controls inside the template.

    Button btn = myGridView.Rows[i].Cells[j].FindControl(my Button1) as Button;

    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]




    "Jonathan Wood" <jwood@softcirc uits.comwrote in message
    news:OflbXcfuIH A.1768@TK2MSFTN GP03.phx.gbl...
    >I have a GridView control with one column a TemplateField that contains two
    >buttons. I'd like to hide one or both button based on the row number.
    >
    Can anyone provide some tips on how I can do this?
    >
    Thanks.
    >
    --
    Jonathan Wood
    SoftCircuits Programming

    >

    Comment

    • Jonathan Wood

      #3
      Re: Access Control in ItemTemplate

      Thanks!

      --
      Jonathan Wood
      SoftCircuits Programming


      "Eliyahu Goldin" <REMOVEALLCAPIT ALSeEgGoldDinN@ mMvVpPsS.orgwro te in
      message news:etlh$KluIH A.6096@TK2MSFTN GP06.phx.gbl...
      Handle PreRender event for the gridview. In the event loop through the
      Rows collection. For every row use Cells collection to locate the column.
      Once on the column, use FindControl method to locate controls inside the
      template.
      >
      Button btn = myGridView.Rows[i].Cells[j].FindControl(my Button1) as Button;
      >
      --
      Eliyahu Goldin,
      Software Developer
      Microsoft MVP [ASP.NET]


      >
      >
      "Jonathan Wood" <jwood@softcirc uits.comwrote in message
      news:OflbXcfuIH A.1768@TK2MSFTN GP03.phx.gbl...
      >>I have a GridView control with one column a TemplateField that contains
      >>two buttons. I'd like to hide one or both button based on the row number.
      >>
      >Can anyone provide some tips on how I can do this?
      >>
      >Thanks.
      >>
      >--
      >Jonathan Wood
      >SoftCircuits Programming
      >http://www.softcircuits.com
      >>
      >
      >

      Comment

      Working...