Access Control in ItemTemplate

  • Thread starter Thread starter Jonathan Wood
  • Start date Start date
J

Jonathan Wood

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.
 
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.Cells[j].FindControl(myButton1) as Button;

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
 
Thanks!

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Eliyahu Goldin said:
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.Cells[j].FindControl(myButton1) as Button;

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Jonathan Wood said:
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.
 
Back
Top