Md Akmal

Md Akmal

  • NA
  • 354
  • 19.1k

checkbox problem

Apr 30 2018 11:17 PM
i m facing problem Specified cast is not valid.
 
when i use checkbox in gridview
 
my code is here..
  1. <asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="false">  
  2. <Columns>  
  3. <asp:TemplateField>  
  4. <ItemTemplate>  
  5. <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%#Eval("active")%>' Text='<%#Eval("id")%>' OnCheckedChanged="CheckBox1_CheckedChanged" AutoPostBack="true" />  
  6. </ItemTemplate>  
  7. </asp:TemplateField>  
  8. <asp:BoundField DataField="name" HeaderText="Name" />  
  9. <asp:BoundField DataField="address" HeaderText="Address" />  
  10. <asp:BoundField DataField="city" HeaderText="City" />  
  11. </Columns>  
  12. </asp:GridView>  
  1. protected void CheckBox1_CheckedChanged(object sender, EventArgs e)  
  2. {  
  3. CheckBox chk = (CheckBox)sender;  
  4. string st = "0";  
  5. if (chk.Checked)  
  6. {  
  7. st = "1";  
  8. }  
  9. nc.id = chk.Text;  
  10. nc.mode = "status";  
  11. nc.active = chk.ToString();  
  12. int eff = nc.manipulatNews(nc);  
  13. if (eff > 0)  
  14. {  
  15. fil_grid();  
  16. }  
  17. }  
plz help me
thank you

Answers (4)