1
votes

Hi guys i need your help !!!!. Is it possible to update data from kendo grid using stored procedure in sql server?

I mean: @Html.Kendo.Grid ->>> Method wich executes stored procedure ; <<<-

All examples that i looked for use "Entity Framework Data Model" for binding data to kendo grid. but i want to use my own class to connect to the database.

public class LessonsDep
{
  public int LesId { get; set; }        
  public int Activated { get; set; }       
  public string TaskTable { get; set; }
}
public class LessonsBusinessLayer
{
   public void changeLessons(LessonsDep lessons){
   string connectionString =   ConfigurationManager.ConnectionStrings["nisa1415"].ConnectionString;

    using (SqlConnection con = new SqlConnection(connectionString))
        {                
        SqlCommand cmd = new SqlCommand("dep.edidBiology",con);
        cmd.CommandType = CommandType.StoredProcedure;

        SqlParameter paramId = new SqlParameter();
        paramId.ParameterName = "@LesId";
        paramId.Value = LessonNameClass.stcLesId;
        cmd.Parameters.Add(paramId);

        SqlParameter paramActivated = new SqlParameter();
        paramActivated.ParameterName = "@Activated";
        paramActivated.Value = lessons.Activated;
        cmd.Parameters.Add(paramActivated);

        SqlParameter paramTaskTable = new SqlParameter();
        paramTaskTable.ParameterName = "@TaskTable";
        paramTaskTable.Value = lessons.TaskTable;
        cmd.Parameters.Add(paramTaskTable);

        con.Open();
        cmd.ExecuteNonQuery();
    }
  }
}
1

1 Answers

0
votes

Do you have any problems using what you proposed?

I mean I'm not using Entity in any of my projects ( I use NHibernate) and I think you can use any ORM or other technic instead to read/save/update/delete data.

Of course you have to get data and return it in the same format kendo grid requires.

    public virtual JsonResult Read([DataSourceRequest] DataSourceRequest request)
    {
        //for example use your code code here for SELECT operation to get
        //all the elements you want. Assign to List<> list variable and voila



        return Json(list.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
    }