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

Hide control in insert mode

4 Answers 209 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Akhil Raj
Top achievements
Rank 1
Akhil Raj asked on 25 May 2010, 07:42 AM
hi all,
   I am using editform to edit my data in radgridview. EditFormType is 'Autogenerated'. I have one problem in insert mode.
I have one status column in the grid. This is not a visible column and i need to show this column in edit mode only. In normal mode and insert mode i need not siplay this control. I specify the template column in grid view as follows

<telerik:GridTemplateColumn UniqueName="Status" HeaderText="Status" Visible="false" > 
    <EditItemTemplate> 
         <asp:CheckBox ID="chk1" runat="server" /> 
    </EditItemTemplate> 
</telerik:GridTemplateColumn> 

In my databound event i try to set visibility of this column. checkbox will hide in the insert mode but the header text exists the same. how to handle that header text also. my code behind is

    Protected Sub Rad_grd1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles Rad_grd1.ItemDataBound  
 
        If (TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode) Then  
            Dim edititem As GridEditFormItem = CType(e.Item, GridEditableItem)  
            If edititem.OwnerTableView.IsItemInserted Then  
                edititem("Status").Visible = False 
            Else  
                edititem("Status").Visible = True 
            End If  
        End If  
 
    End Sub  
 
Only checkbox is hide. please help to handle that header text. If i didnt put header text in design mode, ':' is visible. how to handle this colon (:) in the editmode

4 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 25 May 2010, 09:57 AM
Hello Akhil,

You can try the following code snippet to hide Template column in insert mode.

VB.Net:
  
  
Protected Sub RadGrid1_ItemDataBound(ByVal sender As ObjectByVal e As GridItemEventArgs) 
        If TypeOf e.Item Is GridEditFormInsertItem AndAlso e.Item.OwnerTableView.IsItemInserted Then 
           Dim insertitem As GridEditFormInsertItem = DirectCast(e.Item, GridEditFormInsertItem) 
           insertitem("Status").Parent.Visible = False 
        End If 
    End Sub 
 
 

Regards,
Shinu.
0
Akhil Raj
Top achievements
Rank 1
answered on 26 May 2010, 07:55 AM
thanks friend it working

i have one more doubt. i used captiondatafield and captionformatstring to display main data and some custom data. How can i change this data dynamically when insert and edit mode.
In insert mode i need "Add new data for {0}"
in edit mode i need "Modify data for {0}"
0
Shinu
Top achievements
Rank 2
answered on 26 May 2010, 11:10 AM
Hello Akhil,

Check out the following code snippet to use different CaptionFormatString for edit and insert mode.

VB.Net
 
 Protected Sub RadGrid1_ItemCommand(ByVal source As ObjectByVal e As GridCommandEventArgs) 
        If e.CommandName = "InitInsert" Then 
            RadGrid1.MasterTableView.EditFormSettings.CaptionFormatString = "Add new data" 
        End If 
        If e.CommandName = "Edit" Then 
            RadGrid1.MasterTableView.EditFormSettings.CaptionFormatString = "Modify new data for {0}" 
            RadGrid1.MasterTableView.EditFormSettings.CaptionDataField = "EmployeeID" 
        End If 
  End Sub 
 

Regards,
Shinu.


0
Akhil Raj
Top achievements
Rank 1
answered on 27 May 2010, 06:21 AM
hi shynu,
   Thanks for the help. but i got a small isuue in this.your code work nice. When i click in add new caption change to add new and same as in edit iwth edit caption. But after edit operation if i try add new caption is not displaying.. again i am refreshing the full page and try again with add new its working. After edit operation insert caption is not display in the insert mode.Can you help me

This operation page is opened from another page's gridview using radwindow. Is any possible to add custom data like session variable in capation datafield of editsettings? Please help to solve the display issue
Tags
Grid
Asked by
Akhil Raj
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Akhil Raj
Top achievements
Rank 1
Share this question
or