We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Specified argument was out of the range of valid values.

Thread ID:

Created:

Updated:

Platform:

Replies:

81882 May 21,2009 06:04 PM Mar 12,2018 02:01 AM ASP.NET MVC (Classic) 7
loading
Tags: Grid
Samer Saleh
Asked On May 21, 2009 06:04 PM

Hi,
Im in the process of evaluating syncfusion MVC controls for an internal project. The tools you provide look very promising, so I downloaded the trial version to play with it and see how easy to use. The first thing I tried is to create a simple grid, and I just followed the same example you provide in your tutorial, by displaying a simple list of orders that I get from SQL DB. The Code in the View looks like this, and basically Im trying to display one column grid as follows:

<%Html.Grid(

"MvcGridServerMode","GridModel" ,

column =>{

column.Add(p => p.Id);


}); %>

When I run the application. I get the following exception on the code above :
"Specified argument was out of the range of valid values "
Im not sure why.
The code in the controller looks as follows:

public ActionResult Index()
{
ViewData["Message"] = "Welcome to ASP.NET MVC!";

MvcGridModel model = new MvcGridModel()
{
DataSource = Order.GetOrdersList(),
SkinName = "Syncfusion-Grid-Office2007Black",
ActionMode = "Server",
CaptionText = "Orders",
HeaderText = { "Order ID"}

};
ViewData["GridModel"] = model;



return View();
}
Im not sure what the problem is? But I hope you can help me resolve it so I can continue the evaluation.
Thanks



Muthukumar L [Syncfusion]
Replied On May 25, 2009 12:23 AM

Hi Samer,



Thanks for your interest in Syncfusion products.



The DatasourceType has to be mentioned in Grid’s HtmlHelperExtesion Method. Please refer to the following code snippet, in which Datasource type would be your Orders type.



<%Html.Grid(



"MvcGridServerMode","GridModel" ,



column =>{



column.Add(p => p.Id);



}); %>



Regards,

Muthukumar.L

Frank Raab
Replied On June 19, 2009 08:37 PM

I'm having the same problem, and in the reply above I don't see how that code snippet applies, as it is exactly what the original post contained.

I've noticed if I look at model.DataSource, in the sample code the type looks like this:
model.DataSource
{SELECT TOP (20) [t0].[Order ID] AS [OrderID], [t0].[Customer ID] AS [CustomerID], [t0].[Employee ID] AS [EmployeeID], [t0].[Ship Name] AS [ShipName], [t0].[Ship Address] AS [ShipAddress], [t0].[Ship City] AS [ShipCity], [t0].[Ship Region] AS [ShipRegion], [t0].[Ship Postal Code] AS [ShipPostalCode], [t0].[Ship Country] AS [ShipCountry], [t0].[Ship Via] AS [ShipVia], [t0].[Order Date] AS [OrderDate], [t0].[Required Date] AS [RequiredDate], [t0].[Shipped Date] AS [ShippedDate], [t0].[Freight]
FROM [Orders] AS [t0]
}
model.DataSource.GetType()
{Name = "DataQuery`1" FullName = "System.Data.Linq.DataQuery`

When I try using my linq data source, it looks like this:

model.DataSource
{Table(Orders)}
Context: {MyProject.Models.MyDataContext}
IsReadOnly: false

model.DataSource.GetType()
{Name = "Table`1" FullName = "System.Data.Linq.Table`

The one in the sample is a query, when I try it, it's a table.

Frank

Frank Raab
Replied On June 20, 2009 02:18 PM

A followup:

I tried using the JSON example and got the same error. In this case, though, model.DataSource.GetType() returned List of the model object type. What other arguments in this call can produce this error?

I, too, am evaluating your product for an MVC upgrade to a system which deals with 600,000-800,000 users. The features looks great so far, but step one is to get it to work with Linq. The sample code in your CHM file doesn't match the code in your sample grid app, where you've added an ApplicationController to deal with data context issues.

Frank

Frank Raab
Replied On June 20, 2009 07:29 PM

Further update:

I was able to make my test program work when I provided a column.Add for each and every column in the table. Does this mean I can't use a subset of columns in my grid, that I have to build a complete set of columns, then hide the ones I don't want to see?

Frank

Frank Raab
Replied On June 22, 2009 11:01 AM

Now I've spent a couple of days trying to make the grid work, and I've run into some strange behaviors.

My table has a primary key Guid called Id and another Guid reference called TemplateId. In the Html.Grid call I have

column.Add(p => p.Name);
column.Add(p => p.TemplateId);

When the grid is displayed, the Guid is that of the primary kay Id, not the TemplateId.

I also have a TemplateName text column in the table. If I add
column.Add(p => p.TemplateName);
I get the "Specified argument was out of the range of valid values" error, though none of the values are null or empty.

Do you have any explanation for these behaviors?

Frank

Muthukumar L [Syncfusion]
Replied On June 24, 2009 08:33 AM

Hi Frank,

Thanks for your interest in Syncfusion products.

We are glad to let you know Essential Studio ASP.NET MVC Edition Beta-4 has been launched successfully
Please download and use our latest version at
http://www.syncfusion.com/downloads
Updated Demo’s at
http://samples.syncfusion.com/mvcgriddemo/v7.2.0.39

Grid’s DataSource property accepts any kind of IEnumerable data source. It looks like you are trying to set SQL Query as data source.SQL Query cannot be directly set to datasource.

Please refer the following code snippet for setting data source.
Controller:

[C#]
public ActionResult Index()
{

/// HeaderText property is used to specify the Text to be displayed on the column header
MvcGridModel model = new MvcGridModel()
{
DataSource = MyProject.Models.MyDataContext.Orders.Skip(0).Take(20),
SkinName = "Syncfusion-Grid-Office2007Black",
ActionMode = "Server",
CaptionText = "Orders",
HeaderText = { "Order ID", "Customer ID", "Employee ID", "Ship Name", "Ship Address", "Ship City", "Ship Region", "Ship Postal Code", "Ship Country", "Ship Via", "Order Date", "Required Date", "Shipped Date", "Freight" },
PrimaryKeyColumns = { "OrderID" }
};

ViewData["GridModel"] = model;
return View();
}

View:
[ASPX]
// column.Add() is used add columns in the grid at desired order. This is used to filter out visible columns of the grid.
<%Html.Grid(

"MvcGridServerMode","GridModel" ,
column =>{
column.Add(p => p.OrderID);
column.Add(p => p.CustomerID);
column.Add(p => p.EmployeeID);
column.Add(p => p.ShipName);
column.Add(p => p.ShipAddress);
column.Add(p => p.ShipCity);
column.Add(p => p.ShipRegion);
column.Add(p => p.ShipPostalCode);
column.Add(p => p.ShipCountry);
column.Add(p => p.ShipVia);
column.Add(p => p.OrderDate);
column.Add(p => p.RequiredDate);
column.Add(p => p.ShippedDate);
column.Add(p => p.Freight);
}); %>


We are using SQLCE Data base .
The following code snippet is used in Application controller as connection string

[C#]
public MvcSampleBrowser.Models.Northwind SqlCE
{
get
{
AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);
string connectionString = @"Data Source=|DataDirectory|\Northwind.sdf";
return new MvcSampleBrowser.Models.Northwind(connectionString);
}
}

/// SqlCE.Orders-> we can access Orders table from Northwind.sdf.

LINQ Support

Please visit our JSON samples, LINQ data source is used in the JSON mode.

Adding Subset of columns in the grid:


Please use the following lambda expression to add subset of columns what are all the columns are added here will be added to the visible columns collection and gets displayed, Where scenarios requires all columns to be displayed then the third parameter of the Grid() is not required. Options for adding HeaderText and Format from the view will be included in the coming Release.

There are two ways to achieving this

1)Adding visible column from view

[ASPX]
<%Html.Grid(
"MvcGridServerMode","GridModel" ,
column =>{
column.Add(p => p.OrderID);
column.Add(p => p.CustomerID);
column.Add(p => p.EmployeeID);
column.Add(p => p.ShipName);
}); %>

2)Adding visible columns from controller

[C#]
MvcGridModel model = new MvcGridModel();
model.TableDescriptor.VisibleColumns.Add("OrderID");
odel.TableDescriptor.VisibleColumns.Add("CustomerID");
model.TableDescriptor.VisibleColumns.Add("EmployeeID");
model.TableDescriptor.VisibleColumns.Add("ShipName");


3) TemplateId not Displayed Issue

We are unable to re-produce this issue. Nested table samples are available at

http://samples.syncfusion.com/mvcgriddemo/v7.2.0.39/gettingstarted/expand

Please refer our sample in the above link .If you are still facing problems please send us a sample illustrating the issue.

Please let us know if this helps you.

Regards,
Muthukumar.L

irfan
Replied On March 12, 2018 02:01 AM

Hi Samer,



Thanks for your interest in Syncfusion products.



The DatasourceType has to be mentioned in Grid’s HtmlHelperExtesion Method. Please refer to the following code snippet, in which Datasource type would be your Orders type.



<%Html.Grid(



"MvcGridServerMode","GridModel" ,



column =>{



column.Add(p => p.Id);



}); %>



Regards,

Muthukumar.L



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;