Chriz L

Chriz L

  • NA
  • 220
  • 50.6k

Enable checkbox when user clicks on Edit button (GridView)

Dec 28 2016 5:36 AM
Hello,
I have the following code:
  1. protected void gv_RowEditing(object sender, GridViewEditEventArgs e)  
  2.        {  
  3.            gv.EditIndex = e.NewEditIndex;  
  4.   
  5.            ImageButton lnkRowSelection = (ImageButton)sender;  
  6.            String result = lnkRowSelection.CommandArgument.ToString();  
  7.   
  8.            if(result=="N/A")  
  9.                
  10.           //cbResultManualΝο on gridView must be set to enable.
  11.          // cbResultManualYes on gridView must be set to enable.

  12.             bindGrid();  
  13.        }  
  1. <asp:GridView ID="gv" runat="server" AutoGenerateColumns="false"   
  2.     OnRowCancelingEdit="gv_RowCancelingEdit"   
  3.     OnRowEditing="gv_RowEditing"   
  4.     OnRowUpdating="gv_RowUpdating"  CssClass="mTable">  
  5.     <Columns>  
  6.         <asp:TemplateField HeaderText="Check" ItemStyle-Width="25">  
  7.         <ItemTemplate>  
  8.              <asp:Label ID="lblResultAuto" runat="server" Text='<%#Eval("CheckRes") %>' Width="25"></asp:Label>                
  9.          </ItemTemplate>               
  10.     </asp:TemplateField>  
  11.             <asp:TemplateField HeaderText="Valid" ItemStyle-Width="25">  
  12.         <ItemTemplate>  
  13.          <asp:CheckBox ID="lblResultManual" runat="server" Enabled="False" />            
  14.         </ItemTemplate>  
  15.         <EditItemTemplate>  
  16.              <asp:CheckBox ID="cbResultManualYes" runat="server" Enabled="false"/>    
  17.         </EditItemTemplate>  
  18.     </asp:TemplateField>  
  19.     <asp:TemplateField HeaderText="Not Valid" ItemStyle-Width="25">  
  20.         <ItemTemplate>  
  21.          <asp:CheckBox ID="lblResultManual1" runat="server" Enabled="False" />            
  22.         </ItemTemplate>  
  23.         <EditItemTemplate>  
  24.              <asp:CheckBox ID="cbResultManualΝο" runat="server" Enabled="false"/>    
  25.         </EditItemTemplate>  
  26.     </asp:TemplateField>  
  27.          <asp:TemplateField >  
  28.             <ItemTemplate>  
  29.                 <asp:LinkButton ID="btnEdit" Text="Edit" runat="server" CommandName="Edit" />                        
  30.             </ItemTemplate>  
  31.             <EditItemTemplate>  
  32.                 <asp:LinkButton ID="btnUpdate" Text="Update" runat="server" CommandName="Update" />  
  33.                 <asp:LinkButton ID="btnCancel" Text="Cancel" runat="server" CommandName="Cancel" />  
  34.             </EditItemTemplate>  
  35.         </asp:TemplateField>  
  36.     </Columns>  
  37. </asp:GridView>  
How can I enable cbResultManualΝο and cbResultManualΝο when the user clicks on Edit?

Answers (5)