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 6608319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:35:50+00:00 2026-05-25T19:35:50+00:00

I am trying to bind a New List(Of KeyValuePair(Of String, Integer)) to a listView

  • 0

I am trying to bind a New List(Of KeyValuePair(Of String, Integer)) to a listView
Currently, I have a code off:

Dim TestList As List(Of KeyValuePair(Of String, Integer))
For Each key in GetTPDesc (Which is a list of strings)
    TestList.Add(New KeyValuePair(Of String, Integer)(GetTPDesc.ToString, 0))
Next
For Each ArtFailedPair in Table
    TestAddIndex = ArtFailedPair.Failed
    If TestAddIndex <> 0 Then
        TestList(TestAddIndex -1) = New KeyValuePair(Of String, Integer)(TestList(TestAddIndex -1).Key, TestList(TestAddIndex -1).Value +1)
    End If
Next

Excuse me for the long block of code, I know the implementation is dirty, and the reason why I used List of KeyValuePair, was due to the need on Index-Based colletion, which Dictionary did not provide me as I thought it would.
And then I try to bind with:

listView.DataSource = TestList
listView.DataBind()

And the ItemTemplate has the Eval(“key”) and Eval(“value”), ofcourse. But it gives me an error, it shows me:
System.Data.Objects.ObjectQuery’1[System.String] instead of the GetTPDesc.
And I also think an incorrent integer value, since it seems to be out of whack.
Thanks.

The GetTPDesc:

Dim GetTPDesc = (From tpProducts In context.TestResultLim
                 Where tpProducts.Art_no = productNumber
                 Order By tpProducts.TP_no
                 Select tpProducts.TP_desc)
  • 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-05-25T19:35:50+00:00Added an answer on May 25, 2026 at 7:35 pm

    The error is in the following line:

    For Each key in GetTPDesc
        TestList.Add(New KeyValuePair(Of String, Integer)(key, 0))
    Next
    

    you are adding the query to the list instead of the strings.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom class Contact . I am trying to bind a List<Contact>
I trying to bind List to Listbox. And at the Button1Click method new instance
So I am very new to WPF and trying to bind or assign a
I'm completely new to databinding in WPF, and I'm trying to bind an object
Im trying to bind a list with datetime objects to my repeater. if (e.Item.ItemType
I'm trying to bind a list of custom objects to a WPF Image like
I'm trying to bind a list of integers into an SQLTemplate IN clause like
I’m trying to bind a list of items to a ListBox in WPF. The
I've had a bit of a problem trying to bind a generic list to
I'm trying to bind a ListBox's SelectedItem data to a property. The following code

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.