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

[Solved] I can not make a GridNumericColumn readonly !

3 Answers 204 Views
Grid
This is a migrated thread and some comments may be shown as answers.
hll
Top achievements
Rank 1
hll asked on 12 Mar 2010, 06:12 PM
Hi,

In a page a have combobox and a rad grid.

According to the selected value of combobox,
1-) I am making GridNumericColumn (say Col1) of my radgrid visible = false. (In NeedDataSource method -server side..-)
2-) I am making that GridNumericColumn (Col1) readonly as well. (In NeedDataSource or OnItemCommand method -again on the server side..-)

When I am inserting an item to grid, everything works fine.. (Since it is readonly and hidden, I will not be entering any data to that column.. ) So that column will be updated to database as NULL, which is fine..

But when I am editing the row I just entered, I am getting 'Object reference not set to an instance of an object.' exception..

If I remove the code which makes Col1 readonly, I am not getting this exception..  But I need that Col1 readonly, because I do not want user to enter any data to that column..

What should I do??

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 15 Mar 2010, 08:51 AM
Hi,

You need to  use the  ForceExtractValue property which will force the RadGrid to extract values from EditableColumns that are ReadOnly (or IsEditable is false). So try setting the property for the GridNumericColumn.
" Telerik RadGrid can extract values even from columns that are set as read-only, if the column's property ForceExtractValue is set to:
  • "InBrowseMode" - when deleting records
  • "InEditMode" - when inserting/updating records 
  • "Always" - for all modes

The default value for this property is "None", i.e. the data extraction will not be performed for read-only columns.   "



-Princy
0
hll
Top achievements
Rank 1
answered on 15 Mar 2010, 10:43 AM
I set the force extract value to always. and nothing changed.



To make clear everything;

I have a table in my database like this;

From    To      Price1      Price2
0         100      3              NULL
300     400      5              NULL
240     600     NULL         10
110     330     NULL         15                

In the page I have a combobox; containing these;
-Enable Price1   
-Enable Price2



When user selects 'enable Price1', in the grid I will show;
From    To      Price
0          100     3
300      400     5

And when user wants to insert I will show only three textbox (for From, To, and Price1)
I have Price2 GridNUmericColumn in my grid. But when combobox selected value is 'Enable Price1', I am setting Price2 colmn visible = false, and readonly = true.

So the problem is when user wants to edit an row from grid.. I am getting' Object reference not set to an instance of an object.' exception..


What should I do? Please help...
0
hll
Top achievements
Rank 1
answered on 15 Mar 2010, 02:40 PM
any ideas? please?
Tags
Grid
Asked by
hll
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
hll
Top achievements
Rank 1
Share this question
or