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

EditFormType template, set values on databound

3 Answers 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sf
Top achievements
Rank 1
sf asked on 11 Jan 2011, 05:34 AM
in my radgrid i use template as EditFormType. When I open the edit form for a grid item I want to show or hide a texbos based on the value populated in it. Is it possible to achieve?

thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 11 Jan 2011, 05:50 AM
Hello,

The following code snippet shows how to hide the TextBox control in edit form based on its value.

ASPX:
<telerik:GridBoundColumn DataField="FirstName" UniqueName="FirstName" HeaderText="FirstName">
 </telerik:GridBoundColumn>

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
        {
            GridEditFormItem item = (GridEditFormItem)e.Item;
            TextBox txtbox = (TextBox)item["FirstName"].Controls[0];
            if (txtbox.Text == "your value")
            {
                txtbox.Visible = false;
            }
        }
    }

Thanks,
Princy.
0
sf
Top achievements
Rank 1
answered on 11 Jan 2011, 09:36 AM
thanks Princy, in this event is it also possible to find out whether this formtemplate is opened in edit mode or insert mode?
0
Princy
Top achievements
Rank 2
answered on 11 Jan 2011, 09:44 AM
Hello,


The online documentation shows how to differentiate between edit mode  and insert mode in ItemDataBound/ItemCreated event.
Distinguish edit/insert mode on ItemCreated/ItemDataBound


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