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

Edit form userControl

2 Answers 121 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alexandre
Top achievements
Rank 1
Alexandre asked on 12 Nov 2008, 02:01 PM
Im doing a prof of concept with the Telerik grid but i've hit a wall. I'm unable to access the userControl of the edit form. Here is a sample of my code.

ASPX
<form id="form1" runat="server">  
    <telerik:RadScriptManager ID="ScriptManager1" runat="server" EnableTheming="True">  
    </telerik:RadScriptManager> 
    <div> 
    </div> 
    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" GridLines="None">  
        <HeaderContextMenu EnableTheming="True">  
            <CollapseAnimation Duration="200" Type="OutQuint" /> 
        </HeaderContextMenu> 
        <MasterTableView EnableHeaderContextMenu="True">  
            <RowIndicatorColumn> 
                <HeaderStyle Width="20px" /> 
            </RowIndicatorColumn> 
            <ExpandCollapseColumn> 
                <HeaderStyle Width="20px" /> 
            </ExpandCollapseColumn> 
            <Columns> 
                <telerik:GridEditCommandColumn> 
                </telerik:GridEditCommandColumn> 
                <telerik:GridTemplateColumn HeaderText="500226" UniqueName="ikSpecialty">  
                    <ItemTemplate> 
                        <cc1:Label ID="lblSpecialtyRad" runat="server" Text='<%# GetListString("specialite", "ikspecialite", Container.DataItem("ikspecialite"), "cspecial", True) %>'></cc1:Label> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
            </Columns> 
            <EditFormSettings UserControlName="uscProcedure.ascx" EditFormType="WebUserControl">  
                    <EditColumn UniqueName="EditCommandColumn1">  
                    </EditColumn> 
                </EditFormSettings> 
        </MasterTableView> 
        <FilterMenu EnableTheming="True">  
            <CollapseAnimation Duration="200" Type="OutQuint" /> 
        </FilterMenu> 
    </telerik:RadGrid> 
    </form> 

In the code behind, I am trying to access the user control but it always return 'nothing'.

Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load  
 
        If Not IsPostBack Then 
            SetDatasource()  
            RadGrid1.DataSource = GetIntervAss()  
        End If 
    End Sub 
 
Private Sub RadGrid1_NeedDataSource(ByVal source As ObjectByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource  
        RadGrid1.DataSource = GetIntervAss().DefaultView  
    End Sub 
 
 Private Function GetIntervAss() As DataTable  
        Return DirectCast(Session("dsData"), DataSet).Tables("interventions_associees")  
    End Function 
 
' The MyUserControl is always = NOTHING  
Private Sub RadGrid1_EditCommand(ByVal source As ObjectByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.EditCommand  
          Dim MyUserControl As UserControl = CType(e.Item.FindControl(Telerik.Web.UI.GridEditFormItem.EditFormUserControlID), UserControl)  
    End Sub 
 

Can anyone help me on this?

2 Answers, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 12 Nov 2008, 02:07 PM
Hi Alexandre,

EditCommand is too early to access the control. This command will tell the grid to open the edit form in the next lifecycle and you can access data user control in ItemCreated:

If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
    Dim MyUserControl As UserControl = CType(e.Item.FindControl(Telerik.Web.UI.GridEditFormItem.EditFormUserControlID), UserControl) 
End If

Kind regards,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Alexandre
Top achievements
Rank 1
answered on 12 Nov 2008, 02:12 PM
Thank, it works.
Tags
Grid
Asked by
Alexandre
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Alexandre
Top achievements
Rank 1
Share this question
or