Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8650565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:51:13+00:00 2026-06-12T13:51:13+00:00

I could use some help converting this C# line of code to VB. I

  • 0

I could use some help converting this C# line of code to VB. I am very new to Linq and am having trouble with the syntax…

var rows = GridView1.Rows.Cast<GridViewRow>().Where(a => a != row).ToList();

I have tried a number of online conversion tools and none of them have gotten it right either.

UPDATE:
Here is the full code block….

protected void MoveGridViewRows(object sender, EventArgs e)  {      
    Button btnUp = (Button)sender;      
    GridViewRow row = (GridViewRow)btnUp.NamingContainer;      
    // Get all items except the one selected      
    var rows = GridView1.Rows.Cast<GridViewRow>().Where(a => a != row).ToList();      
    switch (btnUp.CommandName)      
    {          
         case "Up":              
         //If First Item, insert at end (rotating positions)              
              if (row.RowIndex.Equals(0))
                  rows.Add(row);              
              else                 
                  rows.Insert(row.RowIndex - 1, row);              
                  break;          
         case "Down":              
         //If Last Item, insert at beginning (rotating positions)              
              if (row.RowIndex.Equals(GridView1.Rows.Count - 1))                  
                  rows.Insert(0, row);              
              else                 
                  rows.Insert(row.RowIndex + 1, row);              
                  break;      
         }      
         GridView1.DataSource = rows.Select(a => new     
         {          
              FirstName = ((TextBox)a.FindControl("txtFirstName")).Text,          
              LastName = ((TextBox)a.FindControl("txtLastName")).Text,      
         }).ToList();      
         GridView1.DataBind();  
} 

The specific error in VS on compile is….

Error 11 Overload resolution failed because no accessible ‘Where’ can be called with these arguments:
Extension method ‘Public Function Where(predicate As System.Func(Of System.Web.UI.WebControls.GridViewRow, Integer, Boolean)) As System.Collections.Generic.IEnumerable(Of System.Web.UI.WebControls.GridViewRow)’ defined in ‘System.Linq.Enumerable’: Nested function does not have the same signature as delegate ‘System.Func(Of System.Web.UI.WebControls.GridViewRow, Integer, Boolean)’.
Extension method ‘Public Function Where(predicate As System.Func(Of System.Web.UI.WebControls.GridViewRow, Boolean)) As System.Collections.Generic.IEnumerable(Of System.Web.UI.WebControls.GridViewRow)’ defined in ‘System.Linq.Enumerable’: Operator ‘<>’ is not defined for types ‘System.Web.UI.WebControls.GridViewRow’ and ‘System.Web.UI.WebControls.GridViewRow’.

Also…

Error 12 Name ‘a’ is not declared. C:\Users\Documents\Visual Studio 2008\WebSites\vv_home\roeMgr.aspx.vb 51 46 C:\

HERE is the VB code thus far…..

    Protected Sub MoveGridViewRows(ByVal sender As Object, ByVal e As EventArgs)


    Dim btnUp As Button = DirectCast(sender, Button)
    Dim row As GridViewRow = DirectCast(btnUp.NamingContainer, GridViewRow)
    ' Get all items except the one selected      
    Dim rows = GridView1.Rows.Cast(Of GridViewRow)().Where(Function(a) a IsNot row).ToList()


    Select Case btnUp.CommandName
        Case "Up"
            'If First Item, insert at end (rotating positions)              
            If row.RowIndex.Equals(0) Then
                rows.Add(row)
            Else
                rows.Insert(row.RowIndex - 1, row)
            End If
            Exit Select
        Case "Down"
            'If Last Item, insert at beginning (rotating positions)              
            If row.RowIndex.Equals(GridView1.Rows.Count - 1) Then
                rows.Insert(0, row)
            Else
                rows.Insert(row.RowIndex + 1, row)
            End If
            Exit Select
    End Select
    GridView1.DataSource = rows.[Select](a >= New With { _
     .FirstName = DirectCast(a.FindControl("txtFirstName"), TextBox).Text, _
     .LastName = DirectCast(a.FindControl("txtLastName"), TextBox).Text _
    }).ToList()
    GridView1.DataBind()


End Sub

thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:51:14+00:00Added an answer on June 12, 2026 at 1:51 pm
    Dim rows = GridView1.Rows.Cast(Of GridViewRow)().Where(Function(a) a IsNot row).ToList()
    

    for the other, should be

    GridView1.DataSource = rows.Select(Function(a) New With {_         
                  .FirstName = CType(a.FindControl("txtFirstName"), TextBox).Text,_
                  .LastName = CType(a.FindControl("txtLastName"), TextBox).Text_      
             }).ToList()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am really new to Ruby and could use some help with a program.
I'm new to SQL and could use some help in creating a database schema
I could really use some help here. I just created a new bare repo
I'm new to Android programming and could really use some help with a program
I am new to rails so could use some help here. I have followed
I really could use some help in the right direction with this. Thanks!
Learning my way through this stuff and could use some help. I'm trying to
I could use some help breaking down this puzzle. 1) I want to fetch
I could use some help with a problem I've been having: I've started building
I could use some help interpreting results from the Instruments Leaks tool. This is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.