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

Possibilities of datasource

Is possible to load SqlDataSource for to button  on grid? 

1 Reply

VN Vignesh Natarajan Syncfusion Team 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:Grid ID="OrdersGrid" runat="server" AllowPaging="True" > 
                <ej:Column Field="OrderID" HeaderText=" Order ID" IsPrimaryKey="True" TextAlign="Right" Width="75"> 
                 .   .   . 
            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) 
                OrdersGrid.DataSource = Syncfusion.JavaScript.Utils.DataTableToJson(dt); 
        protected void Button_Click(object sender, Syncfusion.JavaScript.Web.ButtonEventArgs e) 
Please get back to us if you need any further assistance 
Vignesh Natarajan. 

Live Chat Icon For mobile
Up arrow icon