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

Hide/Display column in edit mode..

2 Answers 224 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Milan Gurung
Top achievements
Rank 1
Milan Gurung asked on 23 Mar 2009, 12:48 PM
Hi,

Is there anyway that the column can displayed only during the edit mode? In the following code "Budget_Business" column is invisible intially - I would like it to display during the edit mode so that the user will know what was original value before making changes using dropdown list.

 <telerik:RadGrid ID="gridException" runat="server" Font-Names="Verdana" Font-Size="8pt" Skin="Web20" BorderWidth="0px" CellPadding="0" GridLines="None" AllowPaging="True" PageSize="50" AllowCustomPaging="True">
        <MasterTableView AutoGenerateColumns="False" EditMode="InPlace" Width="100%" DataKeyNames="BudgetExceptionID">
        <Columns>
            <telerik:GridBoundColumn DataField="Budget_Business" UniqueName="ReadOnlyBudget_Business" ReadOnly="true" Visible="false"></telerik:GridBoundColumn>
            <telerik:GridDropDownColumn DataSourceID="SrcForBusiness" ListTextField="BusinessName" ListValueField="BusinessName" DataField="Budget_Business" HeaderText="Business" UniqueName="Budget_Business" DropDownControlType="DropDownList"></telerik:GridDropDownColumn>    
        </Columns>
        </MasterTableView>
    </telerik:RadGrid>

Thanks.

Milan G

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 24 Mar 2009, 04:24 AM
Hello Milan Gurung,

Try the following code snippet for showing the column only when in EditMode.

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

Thanks,
Princy.
0
Milan Gurung
Top achievements
Rank 1
answered on 26 Mar 2009, 02:13 PM
Thanks Princy,

Milan G
Tags
Grid
Asked by
Milan Gurung
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Milan Gurung
Top achievements
Rank 1
Share this question
or