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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:16:49+00:00 2026-06-11T05:16:49+00:00

I have a simple DataTable where one of the columns contains unique values. For

  • 0

I have a simple DataTable where one of the columns contains unique values. For example:

ColumnName1   ColumnName2
value1        35
value2        44
value3        10

Because I know that value 1, 2 and 3 will always be different one from another, I would like to get a value of this table only using ColumnName2 and one of the values of ColumnName1.
That would for example be:

searchedValue = DataTable.Rows("value3").Item("ColumnName2) 
'result would be 10

I tried the following examples unsuccessfully:

  • with the DataTable.Select method: returns an array of rows, but I only need one

  • with the DataTable.Rows.IndexOf method: if I understood well, I need to provide the whole row contents for it to be found with this method.

  • 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-11T05:16:50+00:00Added an answer on June 11, 2026 at 5:16 am
    Dim rows() AS DataRow = DataTable.Select("ColumnName1 = 'value3'")
    If rows.Count > 0 Then
         searchedValue = rows(0).Item("ColumnName2") 
    End If
    

    With FirstOrDefault:

    Dim row AS DataRow = DataTable.Select("ColumnName1 = 'value3'").FirstOrDefault()
    If Not row Is Nothing Then
         searchedValue = row.Item("ColumnName2") 
    End If
    

    In C#:

    var row = DataTable.Select("ColumnName1 = 'value3'").FirstOrDefault();
    if (row != null)
         searchedValue = row["ColumnName2"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a situation where previously a simple DataTable worked (because I was using
I have a datatable with three columns Id name value value1 I want to
I have a very simple C# DataTable problem that I cannot seem to wrap
I have a simple form with a single button and a datatable with a
I have a simple Parallel.Foreach loop that has about 1000 rows in the DataTable,
I have a DataTable with multiple columns including AccountNumber, Year, and Month. I am
i have this simple page: <h:form id=form> <p:dataTable value=#{testBean.unitTypeModel} var=elem lazy=true rows=10> <p:column headerText=class>#{elem.class.simpleName}</p:column>
I have the following code that fills dataTable1 and dataTable2 with two simple SQL
I have simple table in Sybase -- Creating table 'SimpleText' CREATE TABLE [dbo].[SimpleText] (
I have simple class with width and height member fields which define number of

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.