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

[Solved] Edit mode for only some columns

4 Answers 112 Views
Grid
This is a migrated thread and some comments may be shown as answers.
pradeep k
Top achievements
Rank 1
pradeep k asked on 25 Nov 2009, 08:32 AM
Hi All,

I have a RadGrid with 10 columns, when i click edit i need to show only some columns in edit mode, howto do this.

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Nov 2009, 08:49 AM
Hello Pradeep,

You can set the ReadOnly property for the columns which are not editable.

    <telerik:GridBoundColumn DataField="ContactName" ReadOnly="true" HeaderText="ContactName"
        UniqueName="ContactName">
    </telerik:GridBoundColumn>

Regards,
Shinu.
0
pradeep k
Top achievements
Rank 1
answered on 25 Nov 2009, 09:40 AM
thank you for the reply,

It is working, but when i click on add new record command, i want all the columns to show for entering the values.


0
Princy
Top achievements
Rank 2
answered on 25 Nov 2009, 10:31 AM
Hi Pradeep K,

Try the following approach by setting the ReadOnly property explicitly when in EditMode, in order to to show all the columns while inserting record.

CS:
 
    protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        foreach (GridColumn col in RadGrid1.Columns) 
        { 
            if (col.ColumnType == "GridBoundColumn" && col.UniqueName == "ContactName"
            { 
                if (e.CommandName == RadGrid.EditCommandName) 
                { 
                    (col as GridBoundColumn).ReadOnly = true
                    col.Visible = false
                } 
                else 
                { 
                    (col as GridBoundColumn).ReadOnly = false
                    col.Visible = true
                } 
            } 
        }     
    } 

Thanks,
Princy.
0
pradeep k
Top achievements
Rank 1
answered on 25 Nov 2009, 10:33 AM
thank you.
Tags
Grid
Asked by
pradeep k
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
pradeep k
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or