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