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

[Solved] how to find control when show the popuped eidt form

3 Answers 114 Views
Grid
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 03 May 2013, 02:05 AM
If the popup window is adding the new record, the textbox in the popuped need to hide,
if the popup window is editing the record , the text box need to display.

how to control the visibility of the textbox control?
Thanks.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 03 May 2013, 03:48 AM
Hi,

Please try  the following code snippet to hide a TextBox in insert mode.

C#:
protected void myRadGrid_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        if (e.Item is GridEditFormInsertItem || e.Item is GridDataInsertItem)
        {
            GridEditFormInsertItem insertItem=(GridEditFormInsertItem)e.Item;
            TextBox txt = (TextBox)insertItem.FindControl("TextBox1");  //if you want to hide an asp:TextBox
            txt.Visible = false;
            TextBox txtbound = (TextBox)insertItem["UniqueName"].Controls[0]; // if you want to hide a BoundColumn
            txtbound.Visible = false;
            txt.Parent.Parent.Visible = false;
            txtbound.Parent.Parent.Visible = false;
        
    }
}

Thanks,
Princy.
0
James
Top achievements
Rank 1
answered on 03 May 2013, 05:54 AM
hi Princy, thank you very much.
It works find in insert mode.
But how to judge the edit mode(by e.Item )? I need to dispaly the textbox in edit mode.
0
Accepted
Princy
Top achievements
Rank 2
answered on 06 May 2013, 08:00 AM
Hi,

Please take a look into the following code snippet.

C#:
protected void myRadGrid_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        if (e.Item is GridEditFormInsertItem || e.Item is GridDataInsertItem)
        {
            GridEditFormInsertItem insertItem=(GridEditFormInsertItem)e.Item;
            TextBox txt = (TextBox)insertItem.FindControl("TextBox1");  //if you want to hide an asp:TextBox
            txt.Visible = false;
            TextBox txtbound = (TextBox)insertItem["UniqueName"].Controls[0]; // if you want to hide a BoundColumn
            txtbound.Visible = false;
            txt.Parent.Parent.Visible = false;
            txtbound.Parent.Parent.Visible = false;
        }
    }
    else
    {
        //in edit mode
        TextBox txt = (TextBox)e.Item.FindControl("TextBox1");  //if you want to hide an asp:TextBox in edit mode
        txt.Visible = true;
    }
}

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