Hide a textbox in inline edit mode

4 posts, 0 answers
  1. ranro
    ranro avatar
    50 posts
    Member since:
    Aug 2007

    Posted 25 Mar 2011 Link to this post

    I have a couple of textbox in an Edit Form Template and I need to show or hide one of these textboxes depending upon the data value for that particular row item.  How would I set this textbox to be invisible in the inline edit mode.
  2. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 26 Mar 2011 Link to this post

    Hi ranro,

    <telerik:GridTemplateColumn HeaderText="test Col1" DataField="TestName"
       UniqueName="TestName">
        <ItemTemplate>
            <asp:Label runat="server" ID="lblTestName" Text='<%# Eval("TestName") %>'></asp:Label>
        </ItemTemplate>
        <EditItemTemplate>
            <telerik:RadTextBox ID="txtTestName"  runat="server">
            </telerik:RadTextBox>
        </EditItemTemplate>
    </telerik:GridTemplateColumn>

    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
          
                if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode))
                {
                    GridEditableItem edititem = (GridEditableItem)e.Item;
                    RadTextBox txtTestName = (RadTextBox )edititem["TestNameColName"].FindControl("txtTestName");
                    txtTestName.Visible=false;
               }
    }

    Thanks,
    Jayesh Goyani
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. ranro
    ranro avatar
    50 posts
    Member since:
    Aug 2007

    Posted 28 Mar 2011 Link to this post

    Jayesh,

    Thanks.  I have one question though.  If the textbox contains the value "show" then how do I make it visible and if it contains the value "noShow"  how do I make it not visible.

    Thanks
  5. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 28 Mar 2011 Link to this post

    hi ranro,

    <asp:TextBox ID="txtFirstName" runat="server" Text=' <%#Eval("FirstName")%>'
                                        Visible='<%#  Eval("FirstName").ToString() == "show" ? Convert.ToBoolean("true") : Convert.ToBoolean("false") %>'></asp:TextBox>

    Thanks,
    Jayesh Goyani
Back to Top