Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to know that suppose we have 15 rows in gridview having autogenerate edit, delete,select button equals true. is it possible that we can disable edit,delete,select button if last row index value equals say 15? or say disable autogenerate buttons for a single row.
Posted
Updated 24-Dec-17 23:58pm

Hi,

try like below.
C#
(gridview1.Rows[15].Cells[5].Control[0]).Enabled = false;
// 15 => row index
// 5 => column index
// 0 => Index of the control collection inside the cell.


hope it helps.
 
Share this answer
 
Comments
Rambo_Raja 22-Jul-13 7:40am    
hi ..its not working...error is: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Karthik Harve 22-Jul-13 7:51am    
you need to set your gridview index values. this is just an example.
ErBhati 22-Jul-13 7:44am    
you can set Index according to your grid view
write this code in Rowdatabound event of Grid View...

(gridview1.Rows[14].Cells[2].Control[0]).Enabled = false;
 
Share this answer
 
v2
Comments
Rambo_Raja 22-Jul-13 7:47am    
Control[0]).Enabled---->Enabled is not comming even when i m writing this code at row databound event
ErBhati 22-Jul-13 7:53am    
what is the type of your controls in grid view .....find them
yes we can disable the button.

just write your condition in RowDataBound event of gridview, find button id by findcontrol and do enabled false.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900