I'm trying out the Client side insert/update/delete sample for RadGrid and am banging my head on a wall trying to figure this out.
In a nutshell when I make the AJAX call to the server I get this Message:
Microsoft JScript runtime error: Function expected
I have the web service setup, and put the service reference in the ASPX page in a telerik handler. And I understand there is a callback function involved to repaint the grid, but I never get the callback.
Incidentally the web service is being invoked and the database is updated.
Any and all advice is greatly appreciated!
<
telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function updateChanges()
{
ProductUpdate.AddProductLineItem(15705, 32608, 2, 1, 1, 1, 1, updateGrid);
}
function updateGrid(result)
{
var tableView = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
var grid = $find("<%= RadGrid1.ClientID %>");
grid.repaint();
}
</script>
</
telerik:RadCodeBlock>
<
telerik:RadScriptManager ID="RadScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="ProductUpdate.asmx" />
</Services>
</telerik:RadScriptManager>
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.Services;
using
System.Web.Script.Services;
using
System.Data;
using
System.Data.SqlClient;
using
System.Configuration;
///
<summary>
///
Summary description for ProductUpdate
///
</summary>
[
WebService(Namespace = "http://tempuri.org/")]
[
WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[
ScriptService]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public
class ProductUpdate : System.Web.Services.WebService {
public ProductUpdate () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[
WebMethod (EnableSession=true)]
public string AddProductLineItem(int bidID, int bidAddressID, int productID, int quantity, double originalPrice, double price) {
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["HarvestWSConnectionString"].ConnectionString);
conn.Open();
string sql = @"INSERT INTO BidDetail (BidId, BidAddressID, ProductID, Quantity, OriginalPrice, Price)
VALUES (@BidId, @BidAddressID, @ProductID, @Quantity, @OriginalPrice, @Price)"
;
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.Parameters.Add(
new SqlParameter("@BidID", bidID));
cmd.Parameters.Add(
new SqlParameter("@BidAddressID", bidAddressID));
cmd.Parameters.Add(
new SqlParameter("@ProductID", productID));
cmd.Parameters.Add(
new SqlParameter("@Quantity", quantity));
cmd.Parameters.Add(
new SqlParameter("@OriginalPrice", originalPrice));
cmd.Parameters.Add(
new SqlParameter("@Price", price));
try
{
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
conn.Close();
return "Brandon was here";
}
}