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.

CS0030: Cannot convert type 'System.Collections.Generic.List<string>' to 'System.Collections.Generic.List<int>'

Thread ID:

Created:

Updated:

Platform:

Replies:

130836 Jun 6,2017 01:07 PM Aug 4,2017 06:55 AM ASP.NET Web Forms 7
loading
Tags: Grid
Dmitrii Kravchenko
Asked On June 6, 2017 01:07 PM

I created a new Syncfusion ASP.Net project, and placed Grid control that is connected to my SQL database.

Code:
<ej:Grid ID="Grid1" runat="server" AllowGrouping="True" CssClass="" DataSourceCachingMode="None" DataSourceID="SqlDataSource1" EnableLoadOnDemand="False" MinWidth="0" SelectedRowIndices="System.Collections.Generic.List`1[System.Int32]">
                <Columns>
                    <ej:Column AllowEditing="False" DataType="number" Field="BuyerId" IsIdentity="True" IsPrimaryKey="True">
                    </ej:Column>
                    <ej:Column DataType="string" Field="Buyer_Name">
                    </ej:Column>
                </Columns>
                <EditSettings AllowEditing="True" />
            </ej:Grid>

When I open the page in browser I see this error:
CS0030: Cannot convert type 'System.Collections.Generic.List<string>' to 'System.Collections.Generic.List<int>'

Line 25:             <ej:Grid ID="Grid1" runat="server" AllowFiltering="True" AllowGrouping="True" AllowPaging="True" AllowSorting="True" CssClass="" DataSourceCachingMode="None" DataSourceID="SqlDataSource1" EnableLoadOnDemand="False" MinWidth="0" SelectedRowIndices="System.Collections.Generic.List`1[System.Int32]">
Can't figure this out, please help.
Thanks!


Saravanan Arunachalam [Syncfusion]
Replied On June 7, 2017 02:34 AM

Hi Dimitrii, 
Thanks for contacting Syncfusion’s support. 
The SelectedRowIndices property used to select the multiple rows in the Grid control and it is not a collection property. So, we suggest you to use the selectedRowIndices property like in the below code example with enabling Multiple Selectiontype on Grid control. 
<ej:Grid ID="Grid1" runat="server"  
            AllowGrouping="True" CssClass=""  
            DataSourceCachingMode="None"  
            DataSourceID="SqlDataSource1"  
            EnableLoadOnDemand="False"  
            MinWidth="0"  
            Selectiontype="Multiple" 
            SelectedRowIndices="2,4">     
                  . . .  
        </ej:Grid> 
 
Regards, 
Saravanan A. 


Johan Cyprich
Replied On July 31, 2017 02:09 PM

I'm getting the same error with this code:

<ej:Grid ID="Grid1" runat='server' AllowFiltering="True" AllowPaging="True" AllowSorting="True" CssClass="" DataSourceCachingMode="None" DataSourceID="SqlDataSource1" EnableLoadOnDemand="False" MinWidth="0" SelectedRowIndices="System.Collections.Generic.List`1[System.Int32]">
            <Columns>
                <ej:Column AllowEditing="False" DataType="number" Field="StoreID" IsIdentity="True" IsPrimaryKey="True">
                </ej:Column>
                <ej:Column DataType="string" Field="LandingDomain">
                </ej:Column>
                <ej:Column DataType="string" Field="LandingFolder">
                </ej:Column>
                <ej:Column DataType="number" Field="StatusID">
                </ej:Column>
            </Columns>
        </ej:Grid>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:uStoreConnectionString %>" SelectCommand="SELECT [StoreID], [LandingDomain], [LandingFolder], [StatusID] FROM [Store]"></asp:SqlDataSource>

I tried the above solution but it didn't work. When I delete

              SelectedRowIndices="System.Collections.Generic.List`1[System.Int32]"

from the Grid properties (Source view), the table appears correctly in the web browser, but when I view the page in Design mode, I get an error showing that the control can't be rendered:

              The DataSourceID of 'Grid1' must be the ID of a control type IDataSource. A control with ID 'SqlDataSource1' could not be found.

The control otherwise works but the error message in Design view could lead to more serious problems.

Thanks.



Saravanan Arunachalam [Syncfusion]
Replied On August 1, 2017 07:35 AM

Hi Johan, 
We are sorry that we are unable to reproduce the reported issue and we have created a sample based on your requirement that can be refer from the below code example. 
And we suspect from your code that you have set the improper value to the SelectedRosIndices which may be the cause of the issue. So, we suggest you to set the SelectedRosIndices value as like in previously provided code example and hence pleas provide following details. 
1.       Share the screenshot of your exact issue. 
2.       Did you change SelectedRowIndices property as we mentioned? 
3.       Did you mean again the issue is occurred even set the SelectedRowIndices as we mentioned? 
4.       If possible, please reproduce the issue in above attached sample. 
Regards, 
Saravanan A. 


Johan Cyprich
Replied On August 1, 2017 03:11 PM

Hi. When SelectedRowIndices are the default value, i.e.

          System.Collections.Generic.List`1[System.Int32]

then I get an error when viewing the page with a web browser. When I set SelectedRowIndices="2,3", an error occurs with the grid in Design view (see attached file), but it displays correctly after I close the file and re-open it. Not sure if that's a bug, but the work around is ok for using the grid. :)


Attachment: Screenshot_20170801_11.42.41.png_9b207df2.zip

Saravanan Arunachalam [Syncfusion]
Replied On August 2, 2017 08:12 AM

Hi Johan, 
We are able to reproduce your reported issue when selecting the columns by using SelectCommand property SqlDataSource control and the specified command (select command) will not execute automatically at the compile time (execute at the run time) which is the cause of your reported issue. So, we suggest you to refresh the schema definition of SqlDataSource control manually from the designer view to resolve your issue. Please refer to below attached video clip. 
Regards, 
Saravanan A. 


Johan Cyprich
Replied On August 3, 2017 12:08 PM

Thanks! Solution works. BTW ... the grid control is amazing. I replaced custom made grids with the Syncfusion one and it reduced the code to 10% of what it was before.


Saravanan Arunachalam [Syncfusion]
Replied On August 4, 2017 06:55 AM

  
Hi Johan,  
Thanks for your update.            
We are happy that the provided information helped you. 
Regards, 
Saravanan A. 


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.

;