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

Hide RadGrid Header Label When Inserting

3 Answers 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
VaRon
Top achievements
Rank 1
VaRon asked on 27 Oct 2014, 02:23 PM
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;
            }
        }

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 27 Oct 2014, 07:19 PM
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
0
VaRon
Top achievements
Rank 1
answered on 27 Oct 2014, 07:23 PM
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.
0
Eyup
Telerik team
answered on 30 Oct 2014, 01:48 PM
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.

 
Tags
Grid
Asked by
VaRon
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
VaRon
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or