asp.net - How to enable a checkbox in Gridview only when it's in the Edit mode? -


this how have checkbox column currently:

          <asp:templatefield headertext="hide/show" itemstyle-horizontalalign="center" sortexpression="hide_show">                 <itemtemplate>                     <asp:checkbox id="hideshowchk" runat="server" checked='<%# bind("hide_show") %>' />                 </itemtemplate>             </asp:templatefield> 

i have no code in code behind because it's not necessary. basically, user can check or uncheck it, won't reflected in database unless go edit mode, check or uncheck it, , hit update changes reflected in database.

is there way have checkbox "disabled" or of sort while it's not in edit mode?

you have use edititemtemplate enabling in edit mode

 <edititemtemplate>  <asp:checkbox id="hideshowchk" runat="server" checked='<%# bind("hide_show") %>' />  </edititemtemplate> 

if still want use check box inside itemtemplate make disable using css or jquery.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -