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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to perform Crud operation in Gridd view through C# code beghind

Thread ID:





119315 Jun 4,2015 10:09 AM UTC Jun 5,2015 11:54 AM UTC ASP.NET Web Forms 1
Tags: Grid
Asked On June 4, 2015 10:09 AM UTC

I am  not able to perform the Crud(create, remove, update and Delete operation)operation on the Grid View from C# code or web services.
When we use  Data Manager through web services  the data is not displayed .
So please tell me how to use data manager through web services.

Balaji Marimuthu [Syncfusion]
Replied On June 5, 2015 11:54 AM UTC

Hi Bhaweshdeepak,

Thanks for using Syncfusion Products.

Based on your requirement we have created a sample using ASP.NET Web Services and performed the CRUD operation using UrlAdaptor in Grid.

Please refer the sample and code snippet below:
Sample: Sample

public class WebService1 : System.Web.Services.WebService


        static string cons = ConfigurationManager.ConnectionStrings["SQLConnectionString"].ConnectionString;

        static SqlConnection con = new SqlConnection(cons);


        public DataTable Get()     


            SqlCommand getData = new SqlCommand();

            getData.CommandText = "usp_DEV_ChangeLog_Select"; // Stored procedure for retrieve data from suppliers table

            getData.CommandType = CommandType.StoredProcedure;

            getData.Connection = con;

            if (con.State != ConnectionState.Open)


            DataTable sqldata = new DataTable();

            SqlDataAdapter sqladapter = new SqlDataAdapter(getData);

            sqldata.TableName = "Suppliers";


            return sqldata;



In the above code snippet, we have created webservices by using the ASP.NET web service and bound dataSource to Grid, in code behind GetDataSource method.

<ej:Grid ID="Grid" runat="server" AllowPaging="true">

        <DataManager Adaptor="UrlAdaptor" URL="Default.aspx/GetDataSource" UpdateURL="Default.aspx/Update" InsertURL="Default.aspx/Insert" RemoveURL="Default.aspx/Remove" />

           . . . . . . .



        [ScriptMethod(ResponseFormat = ResponseFormat.Json)] // Return the JSON formatted result

        public static object GetDataSource(int skip, int take)


            CRUD_Service.WebService1 service = new CRUD_Service.WebService1();

            var sqldata = service.Get();   // Get data from webservices

            DataResult result = new DataResult();

            List<EditableCustomer> data = (from ord in sqldata.AsEnumerable().Skip(skip).Take(take) // Perform skip take for on demand load paging

                                           select new EditableCustomer


                                               SupplierID = ord.ItemArray[0].ToString(),

                                               CompanyName = ord.ItemArray[1].ToString(),

                                               City = ord.ItemArray[5].ToString(),

                                               PostalCode = ord.ItemArray[7].ToString(),

                                               Country = ord.ItemArray[8].ToString()


            result.result = data;

            result.count = sqldata.Rows.Count;


            return result;


        public class DataResult


            public IEnumerable result { get; set; }

            public int count { get; set; }


By using the following code snippet, we can perform the Add, Edit, Delete actions in Grid. Please refer the below code snippet:


        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]

        public static void Update(EditableCustomer value)


            ExecuteToSQL("usp_DEV_ChangeLog_Update", 0, value, "update"); // perform Update action    



        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]

        public static void Insert(EditableCustomer value)


            ExecuteToSQL("usp_DEV_ChangeLog_InsertUpdate", 0, value, "insert"); // perform add action




        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]

        public static void Remove(int key)


            ExecuteToSQL("usp_DEV_ChangeLog_Delete", key, null, "remove"); // perform delete action


Please refer the documentation for more details using UrlAdaptor:

Please let us know if you have any queries.

Balaji Marimuthu


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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