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

InitInsert get created edit form

4 Answers 227 Views
Grid
This is a migrated thread and some comments may be shown as answers.
alsi
Top achievements
Rank 1
alsi asked on 15 Dec 2008, 10:13 AM
Dear All!

I would like to know how can I get my custom Edit control object durint InitInsert Command [Add new record]?
Means I've created a custom edit form:
<EditFormSettings UserControlName="~/Controls/DutTestGridCommandControl.ascx" EditFormType="WebUserControl" />
and I need it's reference, ID or similar during creation because it has a property which I need to set in runtime. Is it possible?

Thanks,
alsi

4 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 15 Dec 2008, 10:59 AM
Hello Alsi,

The Init InsertCommand would be too early to access the usercontrol, instead you can access the UserControl in the ItemCreated event of the Grid as shown below:
cs:
 protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
        { 
            GridEditableItem editedItem = e.Item as GridEditableItem; 
            UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);            
 
        } 
    } 

Thanks
Princy.



0
alsi
Top achievements
Rank 1
answered on 15 Dec 2008, 12:22 PM
Thank U Princy!
0
wal
Top achievements
Rank 1
answered on 15 Oct 2011, 02:01 AM
Hi All
I'm in trouble.
I need to get a RadNumericControl when the InitInsert command is raised or Add new button is clicked.
I've tried with ItemCreated event but it isn't work.

I'd be grateful if anyone let me know how that is work.
0
Princy
Top achievements
Rank 2
answered on 17 Oct 2011, 07:09 AM
Hello Wal,

You can try the following in ItemDataBound event that worked as expected.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
   if (e.Item.OwnerTableView.IsItemInserted && e.Item is GridEditFormInsertItem) 
     
         GridEditFormInsertItem item = (GridEditFormInsertItem)e.Item; 
         RadNumericTextBox txt = (RadNumericTextBox)item["ColumnUniqueName"].Controls[0];
     }  
}

Thanks,
Princy.
Tags
Grid
Asked by
alsi
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
alsi
Top achievements
Rank 1
wal
Top achievements
Rank 1
Share this question
or