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

[Solved] Controls in Edit lose state on postback

2 Answers 140 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jes
Top achievements
Rank 1
Jes asked on 23 Apr 2009, 04:46 PM
I've got a radgrid that has one detail table.  Each row of the master table has a few rad dropdowns, and one of these dropdowns becomes invisible based on selection in another dropdown.  This works fines.  However, if the user selects edit on a row where the dropdown is hidden, and then without canceling the edit, adds a new record or edits a record in the detail table (both of which can cause a postback, depending on user selections) and posts back, the hidden dropdown forgets that it was hidden and appears on the row originally being edited.  I would like to be able to prevent users from adding a new record or editing a record from the detail table/master table if one is already being edited, if that would solve the problem, but I don't know how to achieve this.  If that would not solve the problem, I'm desperate for any other solution.


2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 Apr 2009, 11:11 AM
Hello Jes,

You can actually loop through  the grid items and check if any is is in EditMode on clicking the AddNewRecord button. If any row is in EditMode then cancel the InitInsert action as shown below:
c#:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "InitInsert"
        { 
            if (RadGrid1.EditIndexes.Count != 0
            { 
                e.Canceled = true
            } 
        }  
    } 

Also you can set the AllowMultiRowEdit property of the grid to false so as to enable only one row to be editable at a time.

Thanks
Princy.
0
Jes
Top achievements
Rank 1
answered on 24 Apr 2009, 02:18 PM
Sorry, I've tried that, and not only does it not work, it still causes a postback, so my problem still exists.  This seems to be a bug with Edit in place, as I've found two other threads with the exact same problem and no solution.  I changed my grid to edit forms, and the problem went away.
Tags
Grid
Asked by
Jes
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jes
Top achievements
Rank 1
Share this question
or