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

HeaderText visible when associated field is not visible in EditForms mode.

1 Answer 64 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Judy Markworth
Top achievements
Rank 1
Judy Markworth asked on 02 Aug 2010, 03:26 PM
Hi, I have a grid whose EditMode is set to "EditForms".  When the user chooses to insert a new item, I have several fields that should not be visible (they are visible in edit mode, however).  As shown in the code below, in insert mode, I set the visible property to false on those fields.  This works just fine except for the fact that the HeaderText is still displayed.  How do I hide that HeaderText?  Someone else here asked this question in another thread but it was never answered.  Can you help?

Protected Sub grdMember_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles grdMember.ItemDataBound
    If e.Item.OwnerTableView.DataSourceID = "sdsMember" Then
        If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
            If e.Item.OwnerTableView.IsItemInserted Then
                Dim edititem As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
                Dim acsysid As TextBox = DirectCast(edititem("ACCOUNTING_SYSTEM_ID").Controls(0), TextBox)
                acsysid.Visible = False
                Dim termdate As RadDatePicker = DirectCast(edititem("MEMBER_RB_TERMINATION_DATE").FindControl("rdpTerminationDate"), RadDatePicker)
                termdate.Visible = False
                Dim termcomments As TextBox = DirectCast(edititem("MEMBER_RB_TERMINATION_COMMENTS").FindControl("txtTermComments"), TextBox)
                termcomments.Visible = False
                Dim memberrbactive As CheckBox = DirectCast(edititem("MEMBER_RB_ACTIVE").Controls(0), CheckBox)
                memberrbactive.Visible = False
            End If
        End If
    End If
End Sub
<telerik:GridBoundColumn DataField="ACCOUNTING_SYSTEM_ID" UniqueName="ACCOUNTING_SYSTEM_ID"
    HeaderText="Accounting ID" AutoPostBackOnFilter="true">
    <ItemStyle VerticalAlign="Top" />
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn HeaderText="Term. Date" DataField="MEMBER_RB_TERMINATION_DATE"
    SortExpression="MEMBER_RB_TERMINATION_DATE" UniqueName="MEMBER_RB_TERMINATION_DATE">
    <EditItemTemplate>
         <telerik:RadDatePicker ID="rdpTerminationDate" runat="server" DbSelectedDate='<%# Bind("MEMBER_RB_TERMINATION_DATE", "{0: MM/dd/yy}") %>'>
            <DateInput ID="diTerminationDate" InvalidStyleDuration="100" runat="server">
            </DateInput>
        </telerik:RadDatePicker>
    </EditItemTemplate>
    <ItemTemplate>
        <asp:Label ID="MEMBER_RB_TERMINATION_DATELabel" runat="server" Text='<%# Bind("MEMBER_RB_TERMINATION_DATE", "{0: MM/dd/yy}") %>'></asp:Label>
    </ItemTemplate>
    <ItemStyle VerticalAlign="Top" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="MEMBER_RB_TERMINATION_COMMENTS" HeaderText="Term. Comments"
    SortExpression="MEMBER_RB_TERMINATION_COMMENTS" UniqueName="MEMBER_RB_TERMINATION_COMMENTS">
    <EditItemTemplate>
        <asp:TextBox ID="txtTermComments" runat="server" Text='<%# Bind("MEMBER_RB_TERMINATION_COMMENTS") %>'
            TextMode="multiLine" Rows="5" Columns="40"></asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
        <asp:Label ID="MEMBER_RB_TERMINATION_COMMENTSLabel" runat="server" Text='<%# Eval("MEMBER_RB_TERMINATION_COMMENTS") %>'></asp:Label>
    </ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridCheckBoxColumn DataField="MEMBER_RB_ACTIVE" DataType="System.Boolean"
    HeaderText="Active" SortExpression="MEMBER_RB_ACTIVE" UniqueName="MEMBER_RB_ACTIVE" AutoPostBackOnFilter="true">
    <ItemStyle VerticalAlign="Top" Width="40px" />
    <HeaderStyle Width="45px" />
</telerik:GridCheckBoxColumn>

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 03 Aug 2010, 07:33 AM
Hello Judy,

You can try the following code snippet to hide the control and HeaderText.

VB.Net:
Protected Sub grdMember_ItemDataBound(sender As Object, e As GridItemEventArgs)
    If TypeOf e.Item Is GridEditFormInsertItem AndAlso e.Item.IsInEditMode Then
        If e.Item.OwnerTableView.IsItemInserted Then
            Dim edititem As GridEditFormInsertItem = DirectCast(e.Item, GridEditFormInsertItem)
            edititem("FirstName").Parent.Visible = False
            edititem("MEMBER_RB_TERMINATION_DATE").Parent.Visible = False
            edititem("MEMBER_RB_TERMINATION_COMMENTS").Parent.Visible = False
            edititem("MEMBER_RB_ACTIVE").Parent.Visible = False
        End If
    End If
End Sub

Thanks,
Princy.
Tags
Grid
Asked by
Judy Markworth
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or