We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Insert, Update, Delete using sqlcommand in grid

What is wrong:
I want use sql command to perform action in grid with inlineform, and another controls,
And this code not working.

protected void Grid1_ServerEditRow(object sender, Syncfusion.JavaScript.Web.GridEventArgs e)

{

conn.Open();

Dictionary<string, object> data = e.Arguments["data"] as Dictionary<string, object>;

var MyRID = data.Where(d => d.Key == "RTid").FirstOrDefault();

int myid = Convert.ToInt32(MyRID.Value.ToString());

var RT = data.Where(d => d.Key == "RoomType").FirstOrDefault();

string EditRoom = "UPDATE dbo.RoomTypes SET RoomTypes = @RoomType WHERE RTid = @MYID";

SqlCommand cmd = new SqlCommand(EditRoom, conn);

cmd.Parameters.AddWithValue("@MYID", myid);

cmd.Parameters.AddWithValue("@RoomType", RT.Value.ToString());

cmd.ExecuteNonQuery();

conn.Close();

}


2 Replies

TO Tomasz July 25, 2017 03:11 PM UTC

Ok :) my fault. Because i create another site.master i forgot insert i <form> section this.

<asp:ScriptManager runat="server" EnablePageMethods="true">

<Scripts>

</Scripts>

</asp:ScriptManager>

Now everything work fine




VA Venkatesh Ayothi Raman Syncfusion Team July 26, 2017 04:13 AM UTC

Hi Tomasz, 

Thanks for contacting Syncfusion support. 

We are very happy to hear that your requirement is achieved. 

Regards, 
Venkatesh Ayothiraman. 


Loader.
Up arrow icon