views:

284

answers:

2

Hi

Telerik's RADGrid, basing on their example on http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/programaticlinqupdates/defaultcs.aspx

Problem: I can insert and delete, however updating doesn't work. No error trapped. Data just doesn't change.

From the code below it looks like Telerik Grid is doing some kung-fu behind the scenes to wire things up. I can't see the db receiving any update statements.

Question: anything obvious I'm missing?

protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)
        {
            var editableItem = ((GridEditableItem) e.Item);
            var raceId = (Guid) editableItem.GetDataKeyValue("RaceID");

            //retrive entity form the Db
            var race = DbContext.races.Where(n => n.raceid == raceId).FirstOrDefault();
            if (race != null)
            {
                //update entity's state
                editableItem.UpdateValues(race);

                try
                {
                    //submit chanages to Db
                    DbContext.SubmitChanges();
                }
                catch (Exception f)
                {
                    ShowErrorMessage(f);
                }
            }
        }

Think I may have to go back to their example.. get their db.. and attack from that point of view.

Cheers!

A: 

Do a Rebind after your update. Trying adding

RadGrid1.DataSource = null;
RadGrid1.Rebind();

After your call to DbContext.SubmitChanges(); call, assuming you have implemented _NeedDataSource().

Serapth
Manyt thanks.. didn't do it. I've gone back to the Telerik example and taken out from there. I'll post a link when I get this above problem solved! Cheers.
Dave
Didn't quite solve this issue however best examples I found were in http://www.telerik.com/support/documentation-and-tutorials/step-by-step-tutorial-for-ajax.aspx thanks for the quick response.
Dave
A: 

By default RadGrid has a Property to add New Records. It's style depends upon the inbuilt Skin you apply in your RadGrid. Sometimes you may want to diaplay Custom image instad of the default one. Following code helps you to add Custom image. Here i added a Custom image for "Add New Records" in RadGrid.

<

<

<CommandItemTemplate>         <asp:ImageButton ID = "imgInsert" runat = "server" ImageUrl ="~/Image/icons_add.jpg" CommandName = "InitInsert" ToolTip = "Insert New Record" />

Custom image in Radgrid

eliza sahoo