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. Image for the cookie policy date

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

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!


7 Replies

SA Saravanan Arunachalam Syncfusion Team June 7, 2017 06:34 AM UTC

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. 



JC Johan Cyprich July 31, 2017 06:09 PM UTC

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.




SA Saravanan Arunachalam Syncfusion Team August 1, 2017 11:35 AM UTC

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. 



JC Johan Cyprich August 1, 2017 07:11 PM UTC

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


SA Saravanan Arunachalam Syncfusion Team August 2, 2017 12:12 PM UTC

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. 



JC Johan Cyprich August 3, 2017 04:08 PM UTC

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.



SA Saravanan Arunachalam Syncfusion Team August 4, 2017 10:55 AM UTC

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


Loader.
Up arrow icon