Grid Update


Iam trying to implement the dataprocessor sample in asp.net 2.0 and Iam able to implement the get operation page but iam having problems with the update.



Here is the code which iam using



Get.aspx.cs:



SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings[“ConnectionString”].ConnectionString);

SqlCommand cmd = new SqlCommand(“SELECT * FROM Employee”, con);

SqlDataReader dr;

Response.ContentType = “text/xml”;

Response.ContentEncoding = Encoding.UTF8;

con.Open();

dr = cmd.ExecuteReader();

Response.Write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

Response.Write("");

int i=1;

while(dr.Read())

{

Response.Write("<row id=""+(i++)+"">");

Response.Write("" + dr[0].ToString() + “”);

Response.Write("" + dr[1].ToString() + “”);

Response.Write("" + dr[2].ToString() + “”);

Response.Write("");

}

Response.Write("");

con.Close();

Response.End();





Update.aspx.cs:



SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings[“ConnectionString”].ConnectionString);

SqlCommand cmd = new SqlCommand(“UPDATE Employee SET First_Name=’”+Request[“First_Name”].ToString()+"’, Last_Name=’"+Request[“Last_Name”].ToString()+"’ WHERE Emp_ID=’"+Request[“Emp_ID”].ToString()+"’", con);

Response.ContentType = “text/xml”;

Response.ContentEncoding = Encoding.UTF8;

Response.Write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

con.Open();

cmd.ExecuteNonQuery();

con.Close();

string action = “update”;

string id = Request[“Emp_ID”].ToString();

Response.Write("");

Response.Write("");

Response.Write("");

Response.End();





GridUpdate.aspx:







    Edit

    

    

    

    

    

    

            

    

    

    







 







    









Iam getting an error “Microsoft JScript runtime error: ‘_cellType’ is null or not an object” in dhtmlxgrid.js file on line 213. I need some help to get this working.

The problem is in next line

>>myDataProcessor.setVerificator(3,checkIfNotZero);

You are setting the verificator on column with index 3, but there is no such column ( column indexes are zero based, so in your case you are having only index 0,1,2 )