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 16194When we are running the Application, if any errors occur in the Stored Procedure then how will the server identify the errors?
HCL,
5 11674
What are the advantages and disadvantages of using datalist?
How can you identify whether or not any changes are made to the DataSet object since it was last loaded?
What is the return type of executescalar?
Explain sqlconnection object?
What is data relation in ado.net?
Which object holds only data and does not interact with data source?
Why do we serialize data?
What is the default timeout specified for "sqlcommand.commandtimeout" property?
How will you fill the gridview by using datatable object at runtime?
What is the difference between a datareader and a dataset?
Which is faster sqldataadapter and sqldatareader?
Which method is used to sort the data in ADO.Net?
how we can fire event in databound coulm in datagfrid withot using button?
What is the role of data provider in ado.net?
how you will deal result set? How do you sort a dataset?If a dataset contains 100 rows, how to fetch rows between 5 and 15 only?