Solved

DataView RowFilter

Posted on 2008-10-15
3
3,184 Views
Last Modified: 2013-12-17
I have duplicate values in my dataview and when am binding to the dropdown , i need to populate only unique values onto my dropdown through rowfilter? Any help is appreciated
0
Comment
Question by:venkay
[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
  • 2
3 Comments
 
LVL 12

Expert Comment

by:deanvanrooyen
ID: 22725404
what are you binding from e.g. is the datasource a collection? you can remove duplicate items from the datasource first - probably easier.
0
 
LVL 6

Expert Comment

by:esolve
ID: 22757743
This happens during postback. Sometimes you are calling databind() and it happens automatically. Clearing the dropdownlist before binding is a cheat but not the right way.

 protected void DropDownList1_DataBinding(object sender, EventArgs e)
    {
      DropDownList1.Items.Clear();
    }
0
 
LVL 6

Accepted Solution

by:
esolve earned 125 total points
ID: 22757856
Sorry I take it for granted that you have duplicate items of all values. After reading it again it makes sense that you could have a dataset/resultset with duplicate values because of your query.

Usually a dropdownlist does not have that many items so in this case just use a collection/array to save the distinct values. You will unfortunately have to iterate through the dataset to retrieve your values.

If you want to use a RowFilter I am sure you can do this

DataView dv = ds.DataTable1.DefaultView;
dv.RowFilter = "DISTINCT(Column1)";
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 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