[Webinar] Learn how to a build a cloud-first strategyRegister Now


ASP.net filter on a data table to read unique items

Posted on 2012-08-21
Medium Priority
Last Modified: 2012-08-21

I usually use the following SQL statement coupled with a reader to populate an ASP.net DropDownList. In my latest solution I am trying to read the same items using a filter.
I'm not quite sure how to use Distinct or create get unique items from the following code  
How would I adjust the following line marked XXXX  ?

  xSQLTable_Accounts.DefaultView.RowFilter = "[Segment 1 Desc]=*"  'XXXX

                With Me.Category1.Items
                    For i As Integer = 0 To xSQLTable_Accounts.DefaultView.Count - 1
                        .Add(xSQLTable_Accounts.DefaultView.Item(i).Item("Segment 1 Desc"))
                End With
Question by:Murray Brown
  • 2
LVL 83

Accepted Solution

CodeCruiser earned 2000 total points
ID: 38315821
Change this

xSQLTable_Accounts.DefaultView.RowFilter = "[Segment 1 Desc]=*"  'XXXX


Dim dTemp As DataTable = xSQLTable_Accounts.DefaultView.ToTable(True, "[Segment 1 Desc]")

Then loop through dTemp

Author Closing Comment

by:Murray Brown
ID: 38316094
Thanks very much

Author Comment

by:Murray Brown
ID: 38316205
Minor alteration: had to take square brackets out to get it to work
  Dim dTemp As DataTable = xSQLTable_Accounts.DefaultView.ToTable(True, "Segment 1 Desc")
Thanks again!

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month20 days, 9 hours left to enroll

868 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