Hide RadGrid Header Label When Inserting

4 posts, 0 answers
  1. VaRon
    VaRon avatar
    2 posts
    Member since:
    Sep 2014

    Posted 27 Oct 2014 Link to this post

    Hello,

         I am hoping that someone can help with a requirement I'm trying to accomplish.  What I am trying to accomplish is when a new record is added I am wanting to hide the label and entry textbox based on the value of a dropdown.  I have been able to successfully hide the textbox but I can't find a way to hide the label.  From browsing the net and reading other forums I used the EditFormHeaderTextFormat property to set to empty and it does hide the label, but the issue now is setting the value in the code behind in the selectedindexchanged event back to a value.  I have included sample code for what I have below.  If anyone knows an alternate solution that would work please let me know.

    Aspx
    <telerik:GridTemplateColumn EditFormHeaderTextFormat="" DataField="CHIPReasonOther" DataType="System.String" FilterControlAltText="Filter Reason column" HeaderText="Define Other" SortExpression="ReasonOther" UniqueName="CHIPReasonOther">
                            <EditItemTemplate>
                                <telerik:RadTextBox ID="txtCHIPReasonOther" runat="server" Width="275px" MaxLength="50" Visible="false"></telerik:RadTextBox>
                                <asp:RequiredFieldValidator ID="rqdReasonOther" ControlToValidate="txtCHIPReasonOther" runat="server" ErrorMessage="Required" CssClass="validation" Enabled="false" Display="Dynamic"></asp:RequiredFieldValidator>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="lblCHIPReasonOther" runat="server" Text='<%# Bind("CHIPReasonOther") %>' Enabled="True" Visible="true" />
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>

    Code behind
    protected void rcbTempOOH_SelectedIndexChanged(object o, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
            {
                RadComboBox rcbSender = (RadComboBox)o;
                GridEditFormItem item = rcbSender.NamingContainer as GridEditFormItem;
                RadTextBox txtCHIPReasonOther = item.FindControl("txtCHIPReasonOther") as RadTextBox;
                RequiredFieldValidator rqdReasonOther = item.FindControl("rqdReasonOther") as RequiredFieldValidator;
                var selectedItem = e.Text;
                selectedItem = Regex.Replace(selectedItem, @"\s+", "");
                txtCHIPReasonOther.Text = string.Empty;
     
                if (selectedItem == "Other")
                {
                    txtCHIPReasonOther.Visible = true;
                    rqdReasonOther.Enabled = true;
                }
                else
                {
                    txtCHIPReasonOther.Visible = false;
                    rqdReasonOther.Enabled = false;
                }
            }

  2. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 27 Oct 2014 in reply to VaRon Link to this post

    Hi,

    Please try with the below link.
    http://www.telerik.com/forums/unable-to-hide-label-in-radgrid-in-edit-mode#ClnL77SHd0eK3TM4PMfmGQ

    Let me know if any concern.

    Thanks,
    Jayesh Goyani
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. VaRon
    VaRon avatar
    2 posts
    Member since:
    Sep 2014

    Posted 27 Oct 2014 Link to this post

    Thank you for the link I have used this link and it doesn't work in my case, upon rebinding all selected values have been reset, and using the same logic setting values back does not have any affect.  If I use the logic without rebinding it does not display the header either.
  5. Eyup
    Admin
    Eyup avatar
    3014 posts

    Posted 30 Oct 2014 Link to this post

    Hello VaRon,

    To hide the entire CHIPReasonOther edit row from appearing, you can try to hide the container of the txtCHIPReasonOther control: txtCHIPReasonOther.Parent or txtCHIPReasonOther.Parent.Parent.Visible=false;

    That should do the trick. Please give it a try and let me know if it works for you.

    Regards,
    Eyup
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top