BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
Hi Vincente,
Thanks for using Syncfusion Products.
Based on your requirement we have created a sample using ASP.NET Web Services.
Please refer the sample and code snippet below:
Sample: http://www.syncfusion.com/downloads/support/forum/119714/ze/Sample-985080668
public class WebService1 : System.Web.Services.WebService { static string cons = ConfigurationManager.ConnectionStrings["SQLConnectionString"].ConnectionString; static SqlConnection con = new SqlConnection(cons);
[WebMethod] 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) con.Open(); DataTable sqldata = new DataTable(); SqlDataAdapter sqladapter = new SqlDataAdapter(getData); sqldata.TableName = "Suppliers"; sqladapter.Fill(sqldata); 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.
var dataManager = ej.DataManager({
url: "Default.aspx/GetDataSource",
offline: true, adaptor:"UrlAdaptor"
}); $("#Grid").ejGrid({ dataSource: dataManager, allowPaging: true, }); [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] // Return the JSON formatted result public static object GetDataSource() { 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() // 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() }).ToList();
con.Close(); return data; } |
Hi Hostilio, <script type="text/javascript"> var dataManager = ej.DataManager({ url: "/WebService.asmx/Get", adaptor: new ej.UrlAdaptor(), //"UrlAdaptor", crossDomain: false, offline: false }); var data = []; var query = ej.Query(); query.addParams("userName", "EB_HMACIAS"); var promise = dataManager.executeQuery(query); promise.done(function (e) { data = e.result.result; window.employeeView = { dataSource: ko.observableArray(data), selectedRow: ko.observable(1), currentPage: ko.observable(2), actionBegin: ko.observable(function (args) { if (args.requestType == "grouping") $("#selectedRow").ejNumericTextbox("option", { value: -1 }); }) }; ko.applyBindings(employeeView); }); promise.fail(function (e) { alert(e.error.statusText); }); </script> We have created a sample with thrown an exception manually in the Saravanan A.
Thanks for contacting Syncfusion support.
We can handle the error or any exception using fail event of ejDataManager during the post back. The fail method gets invoked when there is any error while making the request or an exception. Please refer to the below code example.
Sample: http://www.syncfusion.com/downloads/support/forum/121518/ze/KnockoutSample_(2)-918495002
Regards,