interactive | editorial | code | resource 
Demonstrations > Usenet group picker
 

Usenet group picker

Usenet group list

This database of Usenet groups contains approximately 60,000 records.

Try using DbCombo to navigate through the newsgroup hierarchy.

    

Tip: Remember to put a '.' on the end of your search each time to drill-down further. The end of a tree is signified by a '@'.
Some hierarchies to try...
   alt.
   comp.
   microsoft.

The code...

And the code required to produce this functionality? - take a look:

<DbCombo:DbCombo Runat=server ID="Dbcombo1" 
    TextBoxColumns="40" DropDownRows="25" />

<script runat=server>
    [Cambro.Web.DbCombo.ResultsMethod(true)]
    public static object DbComboMethod(
		Cambro.Web.DbCombo.ServerMethodArgs args){
    
        string sqlQuery=args.Query.Replace("@","");
        int level=1;
        for (int i=0; i<sqlQuery.Length; i++)
        {
            //Count the number of '.' characters in the string. 
            //We will only select items at this level.
            if (sqlQuery[i]=='.') 
                level++;
        }
        
        DataSet dataset=new DataSet();
        SqlConnection conn = new SqlConnection("your-connection-string");
        SqlDataAdapter adapter = new SqlDataAdapter();
        
        adapter.SelectCommand = new SqlCommand(@"
            SELECT TOP "+args.Top+@" 
            (   
                convert( varchar (150), ItemFullPath ) +  
                convert( varchar (150), 
                    case when ItemChildren=0 
                    then '@' 
                    else '' end 
                ) 
            ) AS DbComboText, ItemK AS DbComboValue 
            FROM Item 
            WHERE ItemFullPath LIKE @Query 
            AND ItemLevel="+level.ToString()+@" 
            ORDER BY ItemChildren DESC, ItemName", conn);
            
        adapter.SelectCommand.Parameters.Add("@Query",args.Query+"%");
        
        adapter.Fill(dataset);
        conn.Close();
        return dataset;
    }
</script>

(Most of this is SQL code used to retrieve the data... rather than specifically DbCombo).


 
Demonstrations > Usenet group picker