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

How to detect a control like textbox, checkbox,radiobutton,label,hidden field on server side code in c#

Thread ID:

Created:

Updated:

Platform:

Replies:

119289 Jun 2,2015 10:16 AM UTC Jun 5,2015 11:11 AM UTC ASP.NET Web Forms 4
loading
Tags: Grid
Gopi Krishna
Asked On June 2, 2015 10:16 AM UTC

How to detect a control like textbox, checkbox,radiobutton,label,hidden field on server side code in c#

Ezhil S [Syncfusion]
Replied On June 3, 2015 10:47 AM UTC

Hi Gopi,

Thank you for contacting syncfusion support.

We are unable to understand your query on “detect control in code behind” in ASP.NET. That is when the controls are added as child control of some other control, are you trying to find the child controls in server side? In code behind do you intend to find the type of the control or use the child controls in some other processing? Also describe the scenario used at your end on detecting the control and what are the Syncfusion control used in your scenario. This would help us to provide you an appropriate solution.

Please let us know if you have any other queries.

Regards,
Ezhil S

Gopi Krishna
Replied On June 4, 2015 05:36 AM UTC

Sir, actually i want to perform the operations like insert,update,delete in to the
sql server data base table. how to perform these operations on server side code
in c# asp.net. please reply me

Gopi Krishna
Replied On June 4, 2015 05:40 AM UTC

Sir, actually i am working on <ej: id="Grid1" runat=server></ej> grid view
. I  want perform the operations like insert,update,delete to the SQL SERVER database table
how to write the code on server side in c# asp.net. please reply me


Ajith R [Syncfusion]
Replied On June 5, 2015 11:11 AM UTC

Hi Gopi,

Thanks for your update.

Query: I  want perform the operations like insert, update, delete to the SQL SERVER database table. How to write the code on server side in c# asp.net?

We suggest you to use Grid server side events with SQL Stored Procedures to achieve server side CRUD operation in the Grid. Please refer the below description with code snippet for further details.

1.       We can set the Grid DataSourceID property as SqlDataSource element id to render the Grid with SQL data and initiate the Grid with server side editing events such as OnServerAddRow, OnServerEditRow, and OnServerDeleteRow.

 


   <ej:Grid ID="SQLDataGrid" runat="server" AllowPaging="True" AllowSorting="True" DataSourceID="SqlData" OnServerAddRow="SQLDataGrid_ServerAddRow" OnServerEditRow="SQLDataGrid_ServerEditRow" OnServerDeleteRow="SQLDataGrid_ServerDeleteRow">         

            -------

            -------

        </ej:Grid>           


    <asp:SqlDataSource runat="server" ID="SqlData" ConnectionString='<%$ ConnectionStrings:SQLConnectionString %>' SelectCommand="SELECT * FROM [Suppliers]">       

     </asp:SqlDataSource>



2.       We can perform the edit operations in the server side with SQL Stored Procedures based on the event type.



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

    {

        ExecuteToSQL("SQLInsert", e.EventType, e.Arguments["data"]); // SQLInsert stored procedure

    }

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

    {

        ExecuteToSQL("SQLUpdate", e.EventType, e.Arguments["data"]);  // SQLUpdate stored procedure

    }

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

    {

        ExecuteToSQL("SQLDelete", e.EventType, e.Arguments["data"]); // SQLDelete stored procedure

    }


    public static void ExecuteToSQL(string commandText, string eventType, object record)

    {       

        if (eventType == "endDelete")

        {

            // Pass parameter to SQLRemove stored procedure

            ----------

            ----------

        }

        else if (eventType == "endAdd" || eventType == "endEdit")

        {

            // Pass parameter to SQLInsert and SQLUpdate stored procedures

            ------------

            ------------

        }

        ---------

        ---------

    }



For your convenience we have created a simple sample and the same can be downloaded from the below link.

Sample Link: http://www.syncfusion.com/downloads/support/forum/119289/ze/SQLServer_CRUD1423892461

Please let us know if you have any concerns.

Regards,
Ajith R


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

;