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
Code behind
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;
}
}