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

Object DataSource with EditCommand

3 Answers 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Scott Durrett
Top achievements
Rank 1
Scott Durrett asked on 30 Apr 2010, 04:44 PM
I'm VERY new to Telerik so please take into account.  :)

I have a grid that contains a FormTemplate inside the EditFormSettings code block.  This grid is populated from a Class Collection datasource.  When the user clicks "Edit"  I need to populate the controls in my FormTemplate with data from my objects.  So when the use clicks edit  I somehow need to "FindControls" on the edit form and populate it from code behind.  The reason for this is because the edit form contains more fields than is shown in the grid. 

Can someone point me in the right direction or even better show me an example?

Thanks
Scott

3 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 03 May 2010, 08:18 AM
Hi Scott,

Depending on if DataItem of the current edit item is needed or not you can use either ItemCreated or ItemDataBound event. Similar to the following:

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        ((ITextControl) e.Item.FindControl("TextBox1")).Text = "SomeValue";
    }
}


All the best,
Rosen
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Scott Durrett
Top achievements
Rank 1
answered on 03 May 2010, 01:38 PM
Thank you for the response.

Using the ItemCreated method seems to work allowing me to populate the edit form as needed, however,  when I click "update" or "cancel" on the edit form this ItemCreated method fires again.  Is there some way for me to know if the user clicked "update" or "cancel" at this time?

Thanks,
Scott
0
Rosen
Telerik team
answered on 04 May 2010, 01:42 PM
Hello Scott,

In such case you should consider using ItemDataBound instead.

Greetings,
Rosen
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Scott Durrett
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Scott Durrett
Top achievements
Rank 1
Share this question
or