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 16198Post New Mind Tree ADO.NET Interview Questions
Is string value type c#?
What is exclusive and normal mode for repository services?
How can you use a third-party tool in jenkins?
Differentiate between Silverlight 1.0 and Silverlight 2?
Difference between value type & reference types ?
why Nacl solution called as brine solution?
What is a constant?
Can you import Microsoft Excel data to SSRS?
What is the problem with calling setstyle()
What is High Availability feature in Hadoop2?
verbal quiz and answers
What is an open hub service?
What is the difference between a static and a non-static inner class in java programming?
The user wants to launch a linux instance in aws ec2. While configuring security group, the user has selected ssh, http, https protocol. What is the need to select ssh?
write an SQL query to list the employees who joined in the month of January?