Solved

DataView RowFilter

Posted on 2008-10-15
3
3,197 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

617 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