I have a GridView in which I have check box as Item Template, and I am updating the GridView when check box is changed. Here is my GridView code:
<Columns>
<telerik:GridTemplateColumn>
<ItemTemplate>
<asp:CheckBox ID="chkcelar" runat="server" Text="Clear" OnCheckedChanged="chkclearchng" AutoPostBack="true"/>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="BPV_NUM" DataType="System.Int64"
DefaultInsertValue="" HeaderText="BPV No" SortExpression="BPV_NUM"
UniqueName="BPV_NUM">
</telerik:GridBoundColumn>
</Columns>
and here is the c# code through which I am updating grid view
protected void chkclearchng(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection("Data Source=sml; User ID=sml; Password=sml; provider=OraOLEDB.Oracle");
OleDbCommand cmd = new OleDbCommand();
CheckBox chkcelar = ((CheckBox)(sender));
GridDataItem row = ((GridDataItem)(chkcelar.NamingContainer));
long bpvnum = row.Cells[1].Text;
if (chkcelar.Checked ) {
cmd.CommandText = @"update sml.FND_01_11@wbg set CLR_FLG=1, CLR_DTE=sysdate where bpv_num=:bpv_num and bpv_dte=:bpv_dte";
}
else {
cmd.CommandText = @"update sml.FND_01_11@wbg set CLR_FLG=0, CLR_DTE=sysdate where bpv_num=:bpv_num and bpv_dte=:bpv_dte";
}
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
cmd.Parameters.Add(":bpv_num",OleDbType.BigInt).Value = bpvnum;
cmd.Parameters.Add(":bpv_dte",OleDbType.Date).Value = RadComboBox1.SelectedValue;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
The problem is that when I change the check box this error appears:
Input string was not in a correct format.
Can anyone tell what may be the issue and how can I resolve it?
Change your code like this: