Solved

Newbie: Quickly select rows based on unique value

Posted on 2004-09-03
5
209 Views
Last Modified: 2012-06-27
I have a grid with many columns. One column, however, has unique values. Is there any way of programmatically selecting the row corresponding to a value of 10, for example, without checking the contents of every cell in the column?  The grid is unbound.
0
Comment
Question by:rdavis101
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Author Comment

by:rdavis101
ID: 11978585
Maybe use MyTable.PrimaryKey.IndexOf   ... but how?
0
 
LVL 4

Expert Comment

by:Javert93
ID: 11981331
If you only want to show that one record, you can use a DataView to filter the results based on a column value.
0
 

Author Comment

by:rdavis101
ID: 11981353
Actually what I'd like to do is update that one record...but if I have a table with 1000 records, and if it's the last row in the table, I'd rather not waste time by writing a routine to fine the record myself. I was hoping there was some "built in" way of doing it. With the Janus Grid, for example, there's a Find function that takes a value and a column as arguments.
0
 
LVL 4

Accepted Solution

by:
Javert93 earned 50 total points
ID: 11981551
You can do that with the DataView:

    Private Sub UpdateRecord(ByVal dt As DataTable, ByVal id As Integer, ByVal ParamArray updateValsGoHere() As Object)
        Dim dv As New DataView(dt)

        dv.Sort = "pk_column_name"
        Dim rowIndex As Integer = dv.Find(id)
        If rowIndex < 0 Or rowIndex >= dt.Rows.Count Then
            ' The record wasn't found
        Else
            Dim dataRow As DataRow = dt.Rows(rowIndex)
            ' Do your update here using "dataRow", and be
            ' sure to call Update() on the data adapter
            ' to propogate the changes back to the database
        End If
    End Sub
0
 

Author Comment

by:rdavis101
ID: 11981571
Thanks dude.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question