Hide control in insert mode

5 posts, 1 answers
  1. Akhil Raj
    Akhil Raj avatar
    69 posts
    Member since:
    Aug 2012

    Posted 25 May 2010 Link to this post

    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
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 25 May 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Akhil Raj
    Akhil Raj avatar
    69 posts
    Member since:
    Aug 2012

    Posted 26 May 2010 Link to this post

    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}"
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 26 May 2010 Link to this post

    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.


  6. Akhil Raj
    Akhil Raj avatar
    69 posts
    Member since:
    Aug 2012

    Posted 27 May 2010 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017