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

GridView - parameter count mismatch

7 Answers 99 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Paulo
Top achievements
Rank 1
Paulo asked on 06 Jul 2010, 12:50 AM
I'm trying to create an editable grid, and are experiencing the following error when I enter one in a cell: Parameter count mismatch. This only occurs if the gridview is empty, if there is at least one row the problem does not occur. What should I do?

using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Net;  
using System.Windows;  
using System.Windows.Controls;  
using System.Windows.Documents;  
using System.Windows.Input;  
using System.Windows.Media;  
using System.Windows.Media.Animation;  
using System.Windows.Shapes;  
using System.ComponentModel;  
using System.ComponentModel.DataAnnotations;  
 
namespace RadGridViewWithComboBoxColumn  
{  
    public partial class MainPage : UserControl  
    {  
        public MainPage()  
        {  
            InitializeComponent();  
        }  
    }  
 
    public class MainPageViewModel  
    {  
        public MainPageViewModel()  
        {  
            Items = new List<Item>();  
            //Items.Add(new Item() { Name = "Item 1" });  
        }  
 
        public List<Item> Items { getset; }          
    }  
 
    public class Item  
    {  
        private Guid _id;  
 
        public Guid Id  
        {  
            get { return _id; }  
 
            set 
            {  
                if (_id != value)  
                {  
                    _id = value;  
                }  
            }  
        }  
          
        private string _name;  
        [StringLength(100)]  
        [CustomRequired(ErrorMessage = "Name must be informed")]  
        [Display(Name = "Name", Description = "Name")]  
        public string Name  
        {  
            get { return _name; }  
 
            set 
            {  
                if (_name != value)  
                {  
                    _name = value;  
                }  
            }  
        }  
 
        private Guid _colorId1;  
        [CustomRequired(ErrorMessage = "Color 1 must be informed")]  
        [Display(Name = "Color 1", Description = "Color 1")]  
        public Guid ColorId1  
        {  
            get { return _colorId1; }  
 
            set 
            {  
                if (_colorId1 != value)  
                {  
                    _colorId1 = value;  
                }  
            }  
        }  
 
        private Guid _colorId2;  
        [CustomRequired(ErrorMessage = "Color 2 must be informed")]  
        [Display(Name = "Color 2", Description = "Color 2")]  
        public Guid ColorId2  
        {  
            get { return _colorId2; }  
 
            set 
            {  
                if (_colorId2 != value)  
                {  
                    _colorId2 = value;  
                }  
            }  
        }  
 
        private Guid _colorId3;  
        [RadGridViewWithComboBoxColumn.Required(ErrorMessage = "Color 3 must be informed")]  
        [Display(Name = "Color 3", Description = "Color 3")]  
        public Guid ColorId3  
        {  
            get { return _colorId3; }  
 
            set 
            {  
                if (_colorId3 != value)  
                {  
                    _colorId3 = value;  
                }  
            }  
        }  
    }  
 
    public class Color  
    {  
        private Guid _id;  
 
        public Guid Id  
        {  
            get { return _id; }  
 
            set 
            {  
                if (_id != value)  
                {  
                    _id = value;  
                }  
            }  
        }  
 
        private string _name;  
 
        public string Name  
        {  
            get { return _name; }  
 
            set 
            {  
                if (_name != value)  
                {  
                    _name = value;  
                }  
            }  
        }  
    }  
 
    public class DataSource  
    {  
        public DataSource()  
        {  
            Colors = new List<Color>();  
            Colors.Add(new Color() { Id = Guid.NewGuid(), Name = "Green" });  
            Colors.Add(new Color() { Id = Guid.NewGuid(), Name = "Blue" });  
            Colors.Add(new Color() { Id = Guid.NewGuid(), Name = "Yellow" });  
            Colors.Add(new Color() { Id = Guid.NewGuid(), Name = "Gray" });  
            Colors.Add(new Color() { Id = Guid.NewGuid(), Name = "White" });  
        }  
 
        public List<Color> Colors { getset; }  
 
    }  
}  
 
<UserControl x:Class="RadGridViewWithComboBoxColumn.MainPage" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:local="clr-namespace:RadGridViewWithComboBoxColumn" 
    mc:Ignorable="d" 
    d:DesignHeight="300" d:DesignWidth="400" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">  
 
    <UserControl.Resources> 
        <local:GuidConverter x:Key="GuidConverter"/>      
        <local:DataSource x:Key="DataSource"/>  
        <local:MainPageViewModel x:Key="ViewModel"/>  
    </UserControl.Resources> 
 
    <Grid x:Name="LayoutRoot" Background="White" d:DataContext="{d:DesignInstance Type=local:MainPageViewModel, IsDesignTimeCreatable=True}">  
        <telerik:RadGridView Name="radGridView1" AutoGenerateColumns="False" ShowInsertRow="True" CanUserInsertRows="True"  ShowGroupPanel="False"   
                             DataContext="{Binding Source={StaticResource ViewModel}}" ItemsSource="{Binding Items}">  
        <telerik:RadGridView.Columns> 
            <telerik:GridViewDataColumn Header="Nome" UniqueName="" Width="300" DataMemberBinding="{Binding Name}">  
            </telerik:GridViewDataColumn> 
            <telerik:GridViewComboBoxColumn Header="Tipo" Width="145" DataMemberBinding="{Binding ColorId1, Converter={StaticResource GuidConverter}}" 
                                                UniqueName="Color1" SelectedValueMemberPath="Id"    
                                                DisplayMemberPath="Name" ItemsSourceBinding="{Binding Path=Colors, Source={StaticResource DataSource}}">  
            </telerik:GridViewComboBoxColumn> 
            <telerik:GridViewComboBoxColumn Header="Tipo" Width="145" DataMemberBinding="{Binding ColorId2, Converter={StaticResource GuidConverter}}" 
                                            UniqueName="Color2" SelectedValueMemberPath="Id"    
                                            DisplayMemberPath="Name" ItemsSourceBinding="{Binding Path=Colors, Source={StaticResource DataSource}}">  
            </telerik:GridViewComboBoxColumn> 
            <telerik:GridViewComboBoxColumn Header="Tipo" Width="145" DataMemberBinding="{Binding ColorId3, Converter={StaticResource GuidConverter}}" 
                                            UniqueName="Color3" SelectedValueMemberPath="Id"    
                                            DisplayMemberPath="Name" ItemsSourceBinding="{Binding Path=Colors, Source={StaticResource DataSource}}">  
            </telerik:GridViewComboBoxColumn> 
            </telerik:RadGridView.Columns> 
        </telerik:RadGridView> 
    </Grid> 
          
</UserControl> 
 
using System;  
using System.Net;  
using System.Windows;  
using System.Windows.Controls;  
using System.Windows.Documents;  
using System.Windows.Ink;  
using System.Windows.Input;  
using System.Windows.Media;  
using System.Windows.Media.Animation;  
using System.Windows.Shapes;  
using System.Windows.Data;  
using System.Globalization;  
 
namespace RadGridViewWithComboBoxColumn  
{  
    public class GuidConverter : IValueConverter  
    {  
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)  
        {  
            Guid guid = new Guid();  
 
            if (value != null)  
                guid = (Guid)value;  
 
            if (guid.Equals(new Guid()))  
                return DependencyProperty.UnsetValue;  
 
            return guid;  
        }  
 
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)  
        {  
            if (value == null)  
                return new Guid();  
            return value;  
        }  
    }  
}  
 
    public class CustomRequiredAttribute : System.ComponentModel.DataAnnotations.RequiredAttribute  
    {  
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)  
        {  
            return base.IsValid(value is Guid && value.Equals(new Guid()) ? null : value, validationContext);  
        }  
    } 

RadControls version: 2010.1.422.1040

Thanks,
Paulo Corrêa

7 Answers, 1 is accepted

Sort by
0
Marcelo Torres Assis
Top achievements
Rank 1
answered on 06 Jul 2010, 01:17 PM
I have the same problem with gridview. Someone in the support give a return?
0
Yavor Georgiev
Telerik team
answered on 06 Jul 2010, 01:55 PM
Hi,

 I have tried to reproduce your error in a project using the code you provided, but so far I have failed to make it appear on my end. Could you please see if you can reproduce it in the attached solution?

Best wishes,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Paulo
Top achievements
Rank 1
answered on 06 Jul 2010, 02:19 PM

Yavor,

The error happens in this project as well. Informing the Name field and pressing ENTER the error happens. It also occurs when we pass through all the fields with the TAB key. It seems it is a problem in the validation, but that only occurs when there is still no rows in the grid.

Thanks,
Paulo Corrêa.

Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET4.0C; .NET4.0E; MS-RTC LM 8)
Timestamp: Tue, 6 Jul 2010 13:21:02 UTC

Message: Unhandled Error in Silverlight Application
Code: 4004    
Category: ManagedRuntimeError       
Message: System.Reflection.TargetParameterCountException: Parameter count mismatch.
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.Delegate.DynamicInvoke(Object[] args)
   at System.Windows.Threading.DispatcherOperation.Invoke()     

Line: 56
Char: 13
Code: 0
URI: http://localhost:12378/SampleTestPage.aspx

0
Marcelo Torres Assis
Top achievements
Rank 1
answered on 06 Jul 2010, 09:21 PM
Using the attached project could simulate the problem. Any feedback?
0
Yavor Georgiev
Telerik team
answered on 07 Jul 2010, 03:09 PM
Hi Marcelo Torres Assis,

 This issue should be fixed in our Q2 release, which is due some time next week.

All the best,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Paulo
Top achievements
Rank 1
answered on 07 Jul 2010, 03:38 PM
Yavor,

You could simulate the problem? Is there any solution to the problem other than wait for the Q2 release?

Regards,
Paulo Corrêa
0
Yavor Georgiev
Telerik team
answered on 07 Jul 2010, 03:42 PM
Hello Paulo,

 I'm afraid not. Our Q2 release should be out by the end of next week.

Greetings,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Paulo
Top achievements
Rank 1
Answers by
Marcelo Torres Assis
Top achievements
Rank 1
Yavor Georgiev
Telerik team
Paulo
Top achievements
Rank 1
Share this question
or