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

Chosing wich fields appear in the edit mode on run time

1 Answer 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rogério
Top achievements
Rank 2
Rogério asked on 04 Dec 2008, 12:16 PM

Hello everybody,

I'm building a grid with edit and delete options.
In the edit option i need to show only some of the fields i have available in the grid for update, but i'm having problems achieving this.

I saw several examples in the forum but i can't put it to work in my project

I'm populating the grid on run time this way:

                '. Preencher a Grid  
                rg_shoppinglist.DataSourceID = "SqlDataSource1" 
                SqlDataSource1.SelectParameters.Item("idClient").DefaultValue = "1" 
                rg_shoppinglist.MasterTableView.DataKeyNames = New String() {"idwebchart"}  
                rg_shoppinglist.Width = Unit.Percentage(98)  
                rg_shoppinglist.PageSize = 5  
                rg_shoppinglist.AllowPaging = True 
                rg_shoppinglist.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric  
                rg_shoppinglist.AutoGenerateColumns = False 
                rg_shoppinglist.AutoGenerateEditColumn = True 
                rg_shoppinglist.AutoGenerateDeleteColumn = False 
                rg_shoppinglist.AllowSorting = True 
                rg_shoppinglist.Skin = "Sunset" 
                rg_shoppinglist.EnableViewState = True 
 
                '. Configurar   
                Dim boundColumn As GridBoundColumn  
                '. Referência  
                boundColumn = New GridBoundColumn()  
                rg_shoppinglist.MasterTableView.Columns.Add(boundColumn)  
                boundColumn.DataField = "ref" 
                boundColumn.HeaderText = "Referência" 
                boundColumn.EditFormColumnIndex = False 
                Dim myEdit As Boolean = boundColumn.IsEditable  
                '. Designação  
                boundColumn = New GridBoundColumn()  
                rg_shoppinglist.MasterTableView.Columns.Add(boundColumn)  
                boundColumn.DataField = "description" 
                boundColumn.HeaderText = "Designação" 

                '. MORE FIELDS ETC ETC ETC......

After this i tryed doing somethign like this:

    Protected Sub rg_shoppinglist_ItemCommand(ByVal source As ObjectByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rg_shoppinglist.ItemCommand  
        Dim val As Object 
        If e.CommandName = "Edit" Then 
            e.Item.Edit = True 
            e.Item.OwnerTableView.Rebind()  
 
 
            For i As Integer = 0 To e.Item.Controls.Count - 1  
                val = e.Item.Controls(i)  
                val = e.Item.Controls(i).ID  
                e.Item.Controls(i).......... several try outs without sucess  
 
            Next 
 
 
        End If 
    End Sub 

But nothing seems to work...
Please help

1 Answer, 1 is accepted

Sort by
0
Rogério
Top achievements
Rank 2
answered on 04 Dec 2008, 03:30 PM
Got it! with help from Telerik boys
I must set the column as Readonly

boundColumn = New GridBoundColumn()  
rg_shoppinglist.MasterTableView.Columns.Add(boundColumn)  
boundColumn.DataField = "ref" 
boundColumn.HeaderText = "Referência" 
boundColumn.[ReadOnly] = True 
Tags
Grid
Asked by
Rogério
Top achievements
Rank 2
Answers by
Rogério
Top achievements
Rank 2
Share this question
or