Return to Snippet

Revision: 4979
at January 31, 2008 20:10 by rengber


Updated Code
//This was the hard way.  
public static Lookup.StatusDataTable GetStatuses(bool intranetMode)
        {
            //TODO: Handle Intranet vs Internet mode.  
            LookupTableAdapters.StatusTableAdapter sta = new LookupTableAdapters.StatusTableAdapter();
            Lookup.StatusDataTable sdt = sta.GetStatusData();
            DataRow[] rows = sdt.Select("Status <> 'Unapproved' and Status <> 'Closed'");            
            Lookup.StatusDataTable retVal = new Lookup.StatusDataTable(); 
            foreach(DataRow dr in rows)
            {
                retVal.Rows.Add(dr.ItemArray); 
            }
            return retVal; 
        }

//Here's the easy way: 
        public static Lookup.StatusDataTable GetStatuses(bool intranetMode)
        {
            LookupTableAdapters.StatusTableAdapter sta = new LookupTableAdapters.StatusTableAdapter();
            Lookup.StatusDataTable sdt = sta.GetStatusData();
            if (!intranetMode)
            {
                sdt.DefaultView.RowFilter = "Status <> 'Unapproved' and Status <> 'Closed'"; 
            }
            return sdt; 
        }

Revision: 4978
at January 31, 2008 20:01 by rengber


Initial Code
public static Lookup.StatusDataTable GetStatuses(bool intranetMode)
        {
            //TODO: Handle Intranet vs Internet mode.  
            LookupTableAdapters.StatusTableAdapter sta = new LookupTableAdapters.StatusTableAdapter();
            Lookup.StatusDataTable sdt = sta.GetStatusData();
            DataRow[] rows = sdt.Select("Status <> 'Unapproved' and Status <> 'Closed'");            
            Lookup.StatusDataTable retVal = new Lookup.StatusDataTable(); 
            foreach(DataRow dr in rows)
            {
                retVal.Rows.Add(dr.ItemArray); 
            }
            return retVal; 
        }

Initial URL

                                

Initial Description
Pretty intuitive, might be an easier/simpler way.

Initial Title
Filter Expression for a DataTable

Initial Tags
data, filter

Initial Language
C#