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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Insert, Update, Delete using sqlcommand in grid

Thread ID:

Created:

Updated:

Platform:

Replies:

131736 Jul 25,2017 02:38 PM UTC Jul 26,2017 04:13 AM UTC ASP.NET Web Forms 2
loading
Tags: Grid
Tomasz
Asked On July 25, 2017 02:38 PM UTC

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();

}


Tomasz
Replied On 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



Venkatesh Ayothi Raman [Syncfusion]
Replied On 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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;