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

[Solved] How to provide Initial values?

3 Answers 193 Views
Grid
This is a migrated thread and some comments may be shown as answers.
daniel coppee
Top achievements
Rank 1
daniel coppee asked on 15 Feb 2008, 04:15 PM
Hi,

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

Sort by
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:

http://www.telerik.com/help/radcontrols/prometheus/?APIForControlling_Net2.html
http://www.telerik.com/help/radcontrols/prometheus/?grdRetrieveOriginalValuesForEditedItem.html

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
daniel coppee
Top achievements
Rank 1
answered on 30 Mar 2008, 05:34 PM
Hi Stephen,

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)

End If

 
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.

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
daniel coppee
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
daniel coppee
Top achievements
Rank 1
Share this question
or