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

How to find GridNumericColumn?

1 Answer 95 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lubomir
Top achievements
Rank 1
Lubomir asked on 09 Apr 2014, 09:06 AM
I have
<telerik:GridNumericColumn ID
                            DataField="PricePerUnit"  
                            HeaderText="Unit Price"
                            HeaderStyle-HorizontalAlign="Center"
                            UniqueName="PricePerUnit"
                            ItemStyle-HorizontalAlign="Right"
                            DataFormatString="<%$Resources: DataFormats, PRICE_WITH_DOLLAR %>"
                            ></telerik:GridNumericColumn>

I want to catch GridNumericColumn in code behind and set read-only = true;

My scenario is:
If( !theUser.CanEditPrice)
{
  //something like this   
  // myGrid.GetGridNumericColumn("PriceID").ReadOnly = true; // maybe i needed to set ColumnEditorID ?
}

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 Apr 2014, 10:48 AM
Hi Lubomir,

I guess you want to set a column as ReadOnly in edit, you can try the following code snippet.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
  if (e.Item is GridEditableItem && e.Item.IsInEditMode)
  {
    GridEditableItem item = e.Item as GridEditableItem;
    (item["PricePerUnit"].Controls[0] as RadNumericTextBox).ReadOnly = true;
  }
}

Thanks,
Princy
Tags
Grid
Asked by
Lubomir
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or