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

Setting predefined values for controls inside user control on item Edit

1 Answer 36 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Eyal
Top achievements
Rank 1
Eyal asked on 24 Mar 2013, 07:15 AM
hi
after reading this:
http://www.telerik.com/help/aspnet-ajax/grid-inserting-values-usercontrol-formtemplate.html

i want to know if there is away of capturing the item edit from user control as shown in the section,

Setting predefined values for controls inside user control on item insertion
i tryed to do this on editcommand but the conversion returns nothing

i know i can get the item data on the databind on the usercontrol but i want to set a few things before i fill the data from the data object.

can i do this? 
thanks.

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 25 Mar 2013, 04:23 AM
Hi,

You can set the values in ItemDataBound event as shown below.
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
        {
            GridEditFormItem item = (GridEditFormItem)e.Item;
            UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
            TextBox txt= (TextBox)userControl.FindControl("TextBox1");
            txt.Text="your text";
        }
}

Thanks,
Shinu.
Tags
Grid
Asked by
Eyal
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or