How To Update A Column In A DataGrid Using C#.NET? I am getting InvalidCastException as (Specified cast is not valid) while updating 2nd column in a datagrid? Id,firstname,lastname are the three columns of my datagrid respectively. I wanted to edit the second column(lastname) and update it. I did the following code in DataGrid's updatecommand(),but failed to update ! Int varid=(int)DataGrid1.DataKeys[e.Item.ItemIndex]; TextBox lnm=(TextBox)e.Item.Cells[2].Controls[0]; string str=lnm.Text ; SqlCommand cmd=new SqlCommand("update customer set lastname='" + str + "' where id=" + varid + "",con); cmd.ExecuteNonQuery(); DataGrid1.EditItemIndex=- 1; DataGrid1.DataBind();
2 16039Post New Mind Tree ADO.NET Interview Questions
Is string is a keyword in java?
How do I find meta tags?
What is log shipping?
How does hlookup work in excel 2016?
Difference between BI and BW
What is function of master database?
Can we add duplicate keys in a hashmap?
If any stored procedure is encrypted, then can we see its definition in activity monitor?
What a task tracker is in hadoop?
What is formatted output?
What is the standard jsf tag library?
Can a thread have multiple processes?
What is public static void main?
How can you generate a route in ember.js?
Should I use struct or class swift?