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

[Solved] get default Values when Insert Rows

2 Answers 141 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dieter
Top achievements
Rank 1
Dieter asked on 23 Aug 2009, 09:16 PM
Hi,
I use linq and will display the default valuse when the User insert an Record.
That is my solution:


Class:
ublic partial class VersandUnternehmen : INotifyPropertyChanging, INotifyPropertyChanged  
{  
      
    private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);  
      
    private int _VersandunternehmenID;  
      
    private string _Text;  
      
    private int _Sortierung =100 ;  
      
    private string _Memo;  
      
    private System.Data.Linq.Binary _Timestamp;  
      
    private string _Anwendung= ConfigurationSettings.AppSettings["Anwendung"].ToString();  
      
    private EntitySet<VersandServicearten> _VersandServicearten; 

Set the default Values
protected void RG1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)  
    {  
        if (e.CommandName == RadGrid.InitInsertCommandName)  
        {  
            
            VersandUnternehmen vu = new VersandUnternehmen();  
            ListDictionary defaultValues = new ListDictionary();  
 
            defaultValues["Anwendung"] = vu.Anwendung;  
            defaultValues["Sortierung"] = vu.Sortierung;  
            e.Item.OwnerTableView.InsertItem(defaultValues);  
        }  
    } 

Here I have only 2 Values that with geht default values, but in other classes it will be 20-40 Values.
is there  a shorter solution  to set set the defaultvalues?

Thank U
Dieter

2 Answers, 1 is accepted

Sort by
0
Accepted
Yavor
Telerik team
answered on 25 Aug 2009, 08:58 AM
Hi Dieter,

I reviewed the code supplied, and it is optimal and correct.
The inserItem method will preset the default values in the isnert form, if you pass the idictionary collection with the values to is. Having lots of fields would require some overhead with pre-setting the collection entries, but the logic remains the same, and cannot be optimized further.

All the best,
Yavor
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.
0
Dieter
Top achievements
Rank 1
answered on 25 Aug 2009, 02:01 PM
Dear Yavor,
thank you for spending time q my solution.
Is good to know -I'm an beginner-  that I have the best way.

Thank U
Best from
Dieter


Tags
Grid
Asked by
Dieter
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Dieter
Top achievements
Rank 1
Share this question
or