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

accessing form from user control

2 Answers 82 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Elliott
Top achievements
Rank 2
Elliott asked on 18 May 2011, 02:33 PM
I have a RADGrid with update capability-the INSERT and UPDATE done through a user control.  I have a pair of checkboxes on the main form which affect the processing.  How do I pass the values of these checkboxes into the user control (or access them from the user control code behind)?

2 Answers, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 23 May 2011, 01:01 PM
Hello Marianne Seggerman,

You can use the Page property of the user control to access the Web page that holds the grid instance:

MyPageClassName myPage = this.Page;

For more information about WebUserControl editing please review this help article:

Custom edit forms

I hope this helps.

Best wishes,
Martin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Elliott
Top achievements
Rank 2
answered on 23 May 2011, 02:15 PM
<table>
<tr>
    <td>
        <asp:Button ID="btnUpdate" Text="Update" CommandName="Update" Visible='<%# Not (TypeOf DataItem Is Telerik.Web.UI.GridInsertionObject) %>' runat="server" />
        <asp:Button ID="btnInsert" Text="Insert" CommandName="PerformInsert" Visible='<%# (TypeOf DataItem Is Telerik.Web.UI.GridInsertionObject) %>' runat="server" />
    </td>
    <td>
        <asp:CheckBox ID="syncTablet" Text="Synch Tablet?" SkinID="Sunset" runat="server" />
    </td>
    <td>
        <asp:CheckBox ID="syncBFD" Text="Synch BFD?" SkinID="Sunset" runat="server" />
    </td>
</tr>
</table>
thanks
I added a pair of checkboxes to the user control and set them to the value of the checkboxes on the main page
Protected Sub rgStores_ItemDataBound(ByVal source As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgStores.ItemDataBound
    Dim gdItem As GridDataItem = Nothing
    Dim btnDelete As LinkButton = Nothing
    Dim TableName As String = String.Empty
    Dim AddEditStore As UserControl = Nothing
    Dim gefItem As GridDataItem = Nothing
    Dim synchTablet, synchBFD As CheckBox
 
    TableName = e.Item.OwnerTableView.Name
    If TypeOf e.Item Is GridDataItem Then
        gdItem = DirectCast(e.Item, GridDataItem)
        btnDelete = DirectCast(gdItem.Cells(11).Controls(0), LinkButton)
        If btnDelete Is Nothing Then
        Else
            btnDelete.Attributes.Add("onclick", "return ConfirmDelete();")
        End If
    End If
 
    If TypeOf e.Item Is GridEditFormItem _
        AndAlso e.Item.IsInEditMode Then
        AddEditStore = DirectCast(e.Item.FindControl(GridEditFormItem.EditFormUserControlID), UserControl)
        synchTablet = DirectCast(AddEditStore.FindControl("syncTablet"), CheckBox)
        synchBFD = DirectCast(AddEditStore.FindControl("syncBFD"), CheckBox)
        If synchTablet Is Nothing Then
        Else
            synchTablet.Checked = chkTablet.Checked
        End If
        If synchBFD Is Nothing Then
        Else
            synchBFD.Checked = chkBFD.Checked
        End If
    End If
End Sub
Tags
Grid
Asked by
Elliott
Top achievements
Rank 2
Answers by
Martin
Telerik team
Elliott
Top achievements
Rank 2
Share this question
or