I want to develop a asp.net webapplication, but I have a big problem with the gridview and the data editing.
The data is in the gridview.
But if i press the edit-button there comes:
[HttpException (0x80004005): The GridView GridView1 RowEditing triggered the event, which was not treated.]
System.Web.UI.WebControls.GridView.OnRowEditing(GridViewEditEventArgs e) +1321226 System.Web.UI.WebControls.GridView.HandleEdit(Int32 rowIndex) +43 System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +611 System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) +207 System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
Code
But in my code i have the method.
I tried this also with vb, there it works except the update method :/. But not with c# :(((
I don't know what to do :((
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
namespace WebApplication3
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bingridview();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
bingridview();
}
public void bingridview()
{
sql = "select id,name, adress from user"
string connstr = "Data Source=*****;Initial Catalog=pwdb;Integrated Security=True";
SqlConnection conn = new SqlConnection(connstr);
SqlDataAdapter sqladapter;
SqlConnection connection;
DataSet myds = new DataSet();
DataSet changes = new DataSet();
SqlCommand cmd = new SqlCommand(sql, conn);
connection = new SqlConnection(connstr);
//Dim datareader As SqlDataReader
connection.Open();
sqladapter = new SqlDataAdapter(sql, connection);
//sqladapter.SelectCommand = cmd
sqladapter.Fill(myds);
connection.Close();
GridView1.DataSource = myds;
DataBind();
}{
GridView1.EditIndex = e.NewEditIndex;
bindGridView();
}
protected void GridView1_RowUpdating(object sender, GridViewEditEventArgs e)
{
//string val = ((TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text;
}
}
}
TypeScript |
Screen:

Can you please help me with the edit/update-method. I slowly begin to despair :/
Thanks a lot
Peter

Posted Oct 10, 2010, 9:05 PM EDT
Please look out the following links.
http://www.dotnetspider.com/resources/27695-GridView-Edit-Delete-Update-Functionality-with.aspx
http://msdn.microsoft.com/en-us/library/ms972948.aspx
http://www.aspdotnetcodes.com/Simple_Insert_Update_Delete_GridView_Sample.aspx
http://geekswithblogs.net/dotNETvinz/archive/2009/06/10/adding-rows-in-gridview-with-edit-update-and-delete-functionality.aspx
Peter Schmidt3 reputationPosted Oct 11, 2010, 11:47 AM EDT
first problem solved.
But i can't get the values from the textboxes....
Here is a screen from c# code and vb...
Tanks a lot Peter
narasimman g146 reputationPosted Oct 14, 2010, 9:39 PM EDT
Alwayz practice to create event by double click
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
}
That should be GridviewUpdateEventArgs
talha karkun11 reputationPosted Oct 14, 2010, 10:30 PM EDT
u can use following code
TextBox txtGName = new extBox();
txtGName = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtName");
string test = txtGName.Text;
regards
Talha Karkun
Posted Oct 16, 2010, 6:19 AM EDT
{
TextBox txtGName = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtName");
//Here you can access the textbox control values while updating the row.
}
http://geekswithblogs.net/dotNETvinz/archive/2009/06/10/adding-rows-in-gridview-with-edit-update-and-delete-functionality.aspx
Hope this helps you.