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

[Solved] Edit the items inside of FormTemplate

3 Answers 108 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Luke
Top achievements
Rank 1
Luke asked on 12 Jan 2010, 04:22 PM
Hi there!
I would like to know if there is any kind of way to get or set a property of an object that is inside a FormTemplate. For instance:
<telerik:RadGrid ID="RadGrid1" ...> 
    <MasterTableView ...> 
        <EditFormSettings EditFormType="Template"
            <FormTemplate> 
                <telerik:RadPanelBar ID="RPBTemplate" ...> 
                    <Items> 
                        <telerik:RadPanelItem ...> 
                            ... 
                        <telerik:RadPanelItem ...> 
                            ... 
                    </Items> 
                </telerik:RadPanelBar> 
            </FormTemplate> 
        </EditFormSettings> 
    </MasterTableView> 
</RadGrid> 

and I want that in the PageLoad event it sets the visibility of the first RadPanelItem to true and the second one to false. Is that possible? Because I tried some ways but it seems impossible to access to the objects included in the FormTemplate. Or more likely it's possible that I'm not able to do it because of my unexperience in the RadControls, I dunno.

I tried to «surf» the RadGrid1.MasterTableView.EditFormSettings.FormTemplate object, but nothing to do... let me know and thanks in advance!

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 12 Jan 2010, 09:59 PM
Hello Luke,

Try the following code-snippet:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item.IsInEditMode)
    {
        RadPanelBar pbar1 = e.Item.FindControl("RPBTemplate") as RadPanelBar;
    }
}

Regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Luke
Top achievements
Rank 1
answered on 13 Jan 2010, 10:28 AM
Ok maybe it looks much worst than I expected. The code you provided doesn't work, or rather it's not suitable for my prob, although I thought it was enough. Now here the real issue: at the beginning the EditMode of the RadGrid is set in the following way:
  • EditFormType is set to AutoGenerated
  • EditMode is set to InPlace
keep in mind the aspx code of above, because we need then another way to edit/insert an element by using a template instead of «InPlace».

The default way is InPlace and it's always shown in order to allow an on-the-fly insert, but the user can also choose the Template modality by clicking the usual button at the top of RadGrid (if I remember fine it's labelled «Add Element»). If I'm in a situation like this how can I edit the items inside the FormTemplate? 

Your code unfortunately doesn't work, because there's no item in EditMode (I also tried with a foreach-loop for all Items of RadGrid and I checked each of them using the FindControl method, but nothing to do... I'm not able to find the RadPanelBar anyway).

The best way for me it would be to edit the visibility of the items of RadPanelBar on the Command event of RadGrid, but I'm not able to do it.

Let me know thanks!
0
Daniel
Telerik team
answered on 18 Jan 2010, 12:40 PM
Hello Luke,

I'm not sure that I understand your scenario completely. Could you please post your markup in this thread?
In the meantime I recommend you go through this help topic: Accessing cells and rows

Regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Luke
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Luke
Top achievements
Rank 1
Share this question
or