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

How to initiate a row edit from code behind?

2 Answers 123 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ron Michael Zettlemoyer
Top achievements
Rank 1
Ron Michael Zettlemoyer asked on 11 Apr 2011, 08:38 PM
I am building a row button that'll make a duplicate of the row the user clicked.  I want it to then let the user edit the row.  In my particular case I am using the built in popup form to edit the row.

So I have a GridButtonColumn, I catch it in the OnItemCommand event - but how do I initiate the edit on the new row?  Or, bring up the New Row form, loaded with the data from the row I'm copying?

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Apr 2011, 05:33 AM
Hello,

You can specify GridButtonColumn with CommandName "Edit". This will show the row in edit mode. The following code might help you.

ASPX:
<Columns>
 <telerik:GridButtonColumn CommandName="Edit" Text="Edit" UniqueName="Edit" HeaderText="Edit">
 </telerik:GridButtonColumn>
</Columns>

-Shinu
0
Ron Michael Zettlemoyer
Top achievements
Rank 1
answered on 12 Apr 2011, 05:02 PM
Here is what I wound up doing, which I think is rather slick:

1- I added a GridButtonColumn with the CommandName of InitInsert and a CommandArgument of Copy.

2- On the server side, I intercept OnItemCommand and if the CommandName is Insert and the CommandArgument is Copy, I set the defaults of each field to be the values present in the current record.  If it's not I set all the defaults to blank.

Because InitInsert is the build-in command to start a new record, the grid then goes ahead on its own an initiates a new record.  In my case that brings up the pop-up form but it'll do an in-line edit if you set it that way.

If the user hit Duplicate by mistake, they can just cancel the insert and no new record is created.



Tags
Grid
Asked by
Ron Michael Zettlemoyer
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Ron Michael Zettlemoyer
Top achievements
Rank 1
Share this question
or