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

hide template items in edit mode aand display in insert mode

2 Answers 97 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sandeep
Top achievements
Rank 1
sandeep asked on 17 Mar 2009, 01:21 PM
hi every body
          i used insert and update commands in the grid. for this i have used edititemtemplate.
now i want the "PASSWORD" field to be displayed in insert mode and in edit mode it must be invisible.

<telerik:GridTemplateColumn HeaderText="Password" UniqueName="Password" Visible="false">            
            <ItemTemplate>
            <asp:Label runat="server" ID="Password" Text='<%# Eval("Password") %>' />
            
            </ItemTemplate>
                <EditItemTemplate>
                <asp:TextBox runat="server" Style="width: 100px; margin-left: 2px;" ID="TBPassword" ReadOnly="False"
                Text='<%# Bind("Password") %>'   TextMode="Password"/>
                </br>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*please enter password" ControlToValidate="TBPassword"></asp:RequiredFieldValidator>
                 </br>
                 <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
        ErrorMessage="*password must contain atleast 7 and not more than 15 characters" ValidationExpression="\w{6,14}$"
        ControlToValidate="TBPassword"></asp:RegularExpressionValidator>
                 
                  </EditItemTemplate>
            <HeaderStyle Width="120px" />
        </telerik:GridTemplateColumn>


guys
plz help me

2 Answers, 1 is accepted

Sort by
0
sandeep
Top achievements
Rank 1
answered on 17 Mar 2009, 01:33 PM
i tried using

 protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
              {
                 if (e.Item is GridEditableItem && e.Item.IsInEditMode)
                    {
            GridEditableItem item = (GridEditableItem)e.Item;
            item["Password"].FindControl("TBPassword").Visible = false;                 
                      
                     }
         }

but, the password text box became invisible in both insert and edit buttons



0
Shinu
Top achievements
Rank 2
answered on 18 Mar 2009, 05:14 AM
Hi Sandeep,

Give a try with the following approach and see if it helps.

CS:

protected
 void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode&&!e.Item.OwnerTableView.IsItemInserted) 
        { 
            GridEditableItem item = (GridEditableItem)e.Item; 
            item["Password"].FindControl("TBPassword").Visible = false
 
        } 
    } 


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