About the author

Name of author Kevin Brammer lives in Houston and spends most of his time painting, designing, and programming ASP.NET/C#.
E-mail me Send mail

Pages

Advertisements

 

Populate SubSonic DropDown with Distinct Values "System.Data.DataRowView"

by Kevin Brammer 7/24/2008 8:22:00 PM

I was having a little trouble figuring out how to select only distinct values from a column and populate a dropdownlist using SubSonic and ASP.NET 2.0 C#. Here is my solution:

 

SubSonic.Query q = new SubSonic.Query("Projects");
            q.QueryType = SubSonic.QueryType.Select;
            q.DISTINCT();
            q.SelectList = "ClientName";
            q.ORDER_BY("ClientName");
 
            DropDown1.DataSource = q.ExecuteReader();
            DropDown1.DataTextField = "ClientName";
            DropDown1.DataBind();

 

If you are getting "System.Data.DataRowView" when binding the SubSonic DropDown control programmatically, be sure to check if you set the DataTextField property of the DropDown control to the correct column name.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

ASP.NET

Related posts

Comments

1/6/2009 3:44:31 AM

Don't forget to close reader after finished use Idatareader class

m us

Add comment


 

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Powered by BlogEngine.NET 1.3.0.0
Theme by Kevin Brammer