Revisiting passing parameter to User Control Edit form when inserting

2 posts, 0 answers
  1. neebs
    neebs avatar
    106 posts
    Member since:
    Apr 2007

    Posted 02 Aug 2010 Link to this post


    I am struggling with how to pass a context variable to the insert logic in a user control edit form when Add a new Row is selected in a grid. The example I'm modelling this after is here:

    However on the DataBinding event of the user control for GridInsertionObject, I need to get one variable from the parent form, which is the ID of a row in a related table, which is required on insert to tie the inserted row to its parent. I've tried the mechanism here:

    but that doesn't work. In the end, I store the ID I need in a session variable, but I'm not happy with that approach. Is there a simple way to do what I need to do?

    Thanks, Steve

  2. Veli
    Veli avatar
    2002 posts

    Posted 06 Aug 2010 Link to this post

    Hi neebs,

    You can use RadGrid's ItemCreated or ItemDataBound event to reference the user control by ID and pass it any value you need:

    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
        if (e.Item is GridEditFormInsertItem && e.Item.IsInEditMode)
            GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;
            Control editFormControl = insertItem.FindControl(GridEditFormItem.EditFormUserControlID);
            //editFormControl now references your user control
            //you can pass it any value you need here

    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
Back to Top