How do you provide initial values for the grid (when adding a new item)?
Is there some handle to eg. Handles radgrid1.ProvideDefaultRowValues ?
And the same question for intersepting the update command eg. Handles Radgrid1.BeforeRowUpdate?
Thanks
Daniel
3 Answers, 1 is accepted
0
Sebastian
Telerik team
answered on 18 Feb 2008, 04:09 PM
Hello Daniel,
I believe that the documentation topics pointed below provide answers to your questions how to set default values on init insert and fetch the old data for the edited records on update command:
This does seem to work for ReadOnly = "False" but not for ReadOnly = "True" fields
What I have is two extra fields (not to be edited by the user) nl. RegDate and RegPerson. The former being the date of the entry, the latter being the person who made the entry. These two fields should be filled in automatically when a record is inserted or updated. The fields should be visible but read-only for the user.
The code below does not seem to work
What Do I do wrong?
If e.CommandName = Telerik.Web.UI.RadGrid.InitInsertCommandName Then'"Add new" button clicked
e.Canceled =
True
'Prepare an IDictionary with the predefined values
Dim newValues As System.Collections.Specialized.ListDictionary = New System.Collections.Specialized.ListDictionary()
newValues(
"PC_RegPerson_ID") = loggedinUser
newValues(
"PC_RegDate") = Date.Now
'Insert the item and rebind
e.Item.OwnerTableView.InsertItem(newValues)
EndIf
0
Sebastian
Telerik team
answered on 02 Apr 2008, 01:40 PM
Hello Daniel,
Since these columns are marked as read-only, they will not be visible in the edit/insert form of the grid. If you would like to pass the data from these fields on update/insert operation, consider storing the PC_RegPerson_ID and PC_RegDate names in the DataKeyNames collection of the master table and then extract their values inside the UpdateCommand/InsertCommand handlers of the control using DataKeyValues.