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

Data is not saving when i keep few fields readonly=true and display=false

1 Answer 25 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Syed
Top achievements
Rank 1
Syed asked on 15 May 2009, 08:15 PM
Hi,
I am trying to insert/update the data in my RadGrid and but could not able to save. I have few fields on the grid and some of them i change the properties readonly=true and display=false. I don't want to see these fields while editing or inserting. When i save the data is not saving. But when i change readonly=false and display=true, the data is saving. I don't know what exactly went wrong.
Temporary i just disable the textboxes while editing/inserting. 

Can you tell me what is the reason behind this.

Look at the following one i am disabling the textboxes.

Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles RadGrid1.ItemDataBound 
        If (TypeOf e.Item Is GridEditFormInsertItem) AndAlso (e.Item.OwnerTableView.IsItemInserted) Then 
            Dim insertItem As GridEditFormInsertItem = DirectCast(e.Item, GridEditFormInsertItem) 
            Dim txtbx1 As TextBox = DirectCast(insertItem("Resource_Name").Controls(0), TextBox) 
            txtbx1.Text = RadComboBox1.SelectedValue.ToString 
            Dim txtbx2 As TextBox = DirectCast(insertItem("Resource_Year").Controls(0), TextBox) 
            ' txtbx2.Text = Request.QueryString("Resource_Year").ToString 
            txtbx2.Text = Year(Now) 
            Dim txtbx3 As TextBox = DirectCast(insertItem("Resource_Month").Controls(0), TextBox) 
            'txtbx3.Text = Request.QueryString("Resource_Month").ToString 
            txtbx3.Text = Month(Now) 
            Dim txtbx4 As TextBox = DirectCast(insertItem("Resource_week").Controls(0), TextBox) 
            txtbx4.Text = Request.QueryString("ResourceVersion").ToString 
            Dim txtbx5 As TextBox = DirectCast(insertItem("Division_ID").Controls(0), TextBox) 
            txtbx5.Text = Request.QueryString("Division_ID").ToString 
            Dim txtbx6 As TextBox = DirectCast(insertItem("Section_ID").Controls(0), TextBox) 
            txtbx6.Text = Request.QueryString("Section_ID").ToString 
            txtbx6.ReadOnly = True 
            RadGrid1.MasterTableView.Columns(6).Visible = False 
            Dim txtbx7 As TextBox = DirectCast(insertItem("sno").Controls(0), TextBox) 
            txtbx1.Enabled = False 
            txtbx2.Enabled = False 
            txtbx3.Enabled = False 
            txtbx4.Enabled = False 
            txtbx5.Enabled = False 
            txtbx6.Enabled = False 
            txtbx7.Enabled = False 
        End If 
 
        If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then 
            Dim item As GridEditableItem = DirectCast(e.Item, GridEditableItem) 
            Dim txtbx1 As TextBox = DirectCast(item("Resource_Name").Controls(0), TextBox) 
            Dim txtbx2 As TextBox = DirectCast(item("Resource_Year").Controls(0), TextBox) 
            Dim txtbx3 As TextBox = DirectCast(item("Resource_Month").Controls(0), TextBox) 
            Dim txtbx4 As TextBox = DirectCast(item("Resource_week").Controls(0), TextBox) 
            Dim txtbx5 As TextBox = DirectCast(item("Division_ID").Controls(0), TextBox) 
            Dim txtbx6 As TextBox = DirectCast(item("Section_ID").Controls(0), TextBox) 
            Dim txtbx7 As TextBox = DirectCast(item("sno").Controls(0), TextBox) 
 
            txtbx1.Enabled = False 
            txtbx2.Enabled = False 
            txtbx3.Enabled = False 
            txtbx4.Enabled = False 
            txtbx5.Enabled = False 
            txtbx6.Enabled = False 
            txtbx7.Enabled = False 
          
        End If 
   End Sub 











1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 16 May 2009, 01:38 PM
Hi Syed,

I suggest that you set ForceExtractValue property to true for the columns which are with display=false and readonly=true.
For more information, refer to the following article:
Retrieving original values for edited item

Best wishes,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Syed
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or