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

Possibilities of datasource

Thread ID:

Created:

Updated:

Platform:

Replies:

143703 Apr 1,2019 03:24 PM UTC Apr 2,2019 07:18 AM UTC ASP.NET Web Forms 1
loading
Tags: Grid
Guadalupe
Asked On April 1, 2019 03:24 PM UTC

Hello
Is possible to load SqlDataSource for to button  on grid? 

Vignesh Natarajan [Syncfusion]
Replied On April 2, 2019 07:18 AM UTC

Hi Guadalupe, 
 
Thanks for using Syncfusion products. 
 
Query: “Is possible to load SqlDataSource for to button  on grid? 
 
From your query, we suspect that you need to update the dataSource of Grid on button click using SqlDataSource. We have achieved your requirement using EJ Button OnClick event. 
  
Kindly refer the code example and sample for your reference.  
 
  
<ej:Button ID="Button" runat="server" Type="Button" Text="Update Sql DataSource" Size="Large" Width="80px" OnClick="Button_Click"> 
</ej:Button> 
     <ej:Grid ID="OrdersGrid" runat="server" AllowPaging="True" > 
          <Columns> 
                <ej:Column Field="OrderID" HeaderText=" Order ID" IsPrimaryKey="True" TextAlign="Right" Width="75"> 
                </ej:Column> 
                 .   .   . 
      </ej:Grid> 
 
Serverside:- 
            DataTable dt = new DataTable("Order"); 
        protected void Page_Load(object sender, EventArgs e) 
        { 
             
 
        } 
        protected void dataBind() 
        { 
 
             
                SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLConnectionString"].ToString()); 
                dt = new DataTable("Order"); 
                SqlCommand cmd = new SqlCommand(); 
                cmd.Connection = myConnection; 
                cmd.CommandText = "select * from Orders"; 
                cmd.CommandType = CommandType.Text; 
                SqlDataAdapter da = new SqlDataAdapter(); 
                da.SelectCommand = cmd; 
                if (myConnection.State == ConnectionState.Closed) 
                { 
                    myConnection.Open(); 
                } 
                da.Fill(dt); 
                OrdersGrid.DataSource = Syncfusion.JavaScript.Utils.DataTableToJson(dt); 
                OrdersGrid.DataBind(); 
                myConnection.Close(); 
             
 
        } 
 
        protected void Button_Click(object sender, Syncfusion.JavaScript.Web.ButtonEventArgs e) 
        { 
 
            dataBind(); 
 
        } 
 
Please get back to us if you need any further assistance 
 
Regards, 
Vignesh Natarajan. 
 


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.

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

Live Chat Icon For mobile
Live Chat Icon