This is a migrated thread and some comments may be shown as answers.

RadGrid EditForm (GridCommandEventArgs? GridUpdatedEventArgs?)

2 Answers 259 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Karl Rohrbach
Top achievements
Rank 1
Karl Rohrbach asked on 07 Feb 2011, 10:15 PM
I am struggling with understanding what event args to use for the DataGrid EditForm.  I appear to either not have the correct OnItemCommand or OnUpdatedCommand in combination with the correct event args.   All the examples I have seen do not have good examples of the EditForm and doing the updates in a code behind using a web service.

<radgrid>
    <mastertableview>
        <columns>
            <telerik bound column>
        </columns>
        <editformsettings>
            <formtemplate>
                <my form items>
                <my button with command name update>                
            </formtemplate>
        </editformsettings>
    </mastertableview>
</radgrid>

I have the following in my radgrid:
OnItemCommand="RadgridItem_Update"

In have the following in my code behind:
protected void RadgridItem_Update(object sender, GridCommandEventArgs e)
    {
        GridEditFormItem myitem = (GridEditFormItem)e.Item;
        etc. etc.  call web service update.
    }

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 08 Feb 2011, 01:02 PM
Hello Karl,

You can either attach 'OnItemCommand' event to Radgrid or can use 'OnUpdateCommand' and perform update opeartion.

ASPX:
<telerik:RadGrid ID="RadGrid1"  OnItemCommand="RadGrid1_ItemCommand">

C#:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == "Update")
        {
            GridEditFormItem myitem = (GridEditFormItem)e.Item;
            // update grid item
        }
    }

ASPX:
<telerik:RadGrid ID="RadGrid1"  OnUpdateCommand="RadGrid1_UpdateCommand" >

C#:
protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
   {
       GridEditFormItem myitem = (GridEditFormItem)e.Item;
       // update grid item
   }

-Shinu.
0
Karl Rohrbach
Top achievements
Rank 1
answered on 08 Feb 2011, 06:10 PM
Thanks Shinu.  I believe my problem was that my CommandName in my asp:Button was not "Update"  I thought you could name the CommandName anything you wanted.  But apparently there are recognized CommandNames. 
Tags
Grid
Asked by
Karl Rohrbach
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Karl Rohrbach
Top achievements
Rank 1
Share this question
or