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 16180hi i have a problem regarding to datagrid in aspdotnet.i have a datagrid in my application.i have to place add,edit,delete buttons or links what ever it may be. now the problem is if i click on add button then the page has to redirected to another form called "xyz.aspx" and if i click on edit button the page has to redirected to another form called "abc.aspx".i am phasing the problem that if where ever i click on the datagrid the cursor goes to gv1_SelectedIndexChanged event.please tell me the solution about the code.
4 8116What are the test cases, we can write for Data Grid. Anybody can help me..Thanks in advance.
5 35023
What is difference between datagrid and flexgrid?
What tags do you need to add within the asp:datagrid tags to bind columns manually.
If we write any code for DataGrid methods, what is the access specifier used for that methods in the code behind file and why?
What are 3 main differences between flexgrid control and dbgrid control?
Is it possible to Manipulate data through flexgrid? Explain.
Power grids in two adjacent states(A&B) are interconnected. Can power grid in state A can be represented by Thevenin Equivalent Circuit. If not explain Why?
Code for Presenting Parent/Child Data in a Data Grid Row?
How to Display the selected row of a DBGrid in a different color?
How to Change the font style of a dbgrid row ?
How to Select a cell in a DBGrid ?
How to print a TStringGrid or a TDBGrid ?
How to activate different hints for each cell in a grid?
How to Get current record from a TDBGrid ?
How to Access a grid's column or row by name ?
How to Resize StringGrid Columns ?