C1GridView and EntityDataSource

Posted by: kaytea on 10 September 2017, 11:41 am EST

  • Posted 10 September 2017, 11:41 am EST

    Hi,

    I have C1GridView bound to an ASP.Net EntityDataSource with Update enabled. I have the following code for the update:

    CS:

    protected void gvC1Items_RowUpdating(object sender, C1GridViewUpdateEventArgs e)
    {
    // update the datasource
    gvC1Items.Update();
    // Reset the edit mode for the current item
    gvC1Items.EditIndex = -1;

    //// Refresh the grid
    UpdateItemGrid();
    }

    private void UpdateItemGrid()
    {
    gvC1Items.DataBind();
    if (gvC1Items.EditIndex != -1)
    {
    drawEditingSymbol(gvC1Items.EditIndex);
    }

    }

    protected void drawEditingSymbol(int rowIndex)
    {
    Image img = new Image();
    img.ImageUrl = "../img/editing.gif";
    gvC1Items.Rows[rowIndex].Cells[0].HorizontalAlign = HorizontalAlign.Center;
    gvC1Items.Rows[rowIndex].Cells[0].Controls.Add(img);
    }


    However, i got an error at
    gvC1Items.Update();
    . Error is "invalid Datasource". How do I accomplish updating with an EntityDataSource? Appreciate your help.
  • Replied 10 September 2017, 11:41 am EST

    Well, I manually updated it through the object context, called SaveChanges(), and that worked. I guess I can't avoid the extra code. I was hoping the EntityDS would take care of changes automatically.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels