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 16180When we are running the Application, if any errors occur in the Stored Procedure then how will the server identify the errors?
HCL,
5 11655
What are two types of transaction supported by ado.net?
Define Execute Scalar?
What are all the classes that are available in System.Data Namespace?
What are the benefits of using ado.net?
How to identify the controls which can be used for binding data?
Explain the role of data provider in ado.net? What is the role of data provider in ado.net?
What is a string variable?
What is openquery?
What are the drawbacks of using ado.net?
Explain the advantages and disadvantages of using datalist?
What is the return type of executescalar?
What is an example of ordinal data?
oledbdataadpter with ms access in c#.net giving exception System.Data.OleDb.OleDbException while writing adapter.update(dataset,"tabname"); how to update the database from dataset?
What is a control toolbox?
how Sequence to connect and retrieve data from database using dataset?