Bind Object to several Control

Bind Object to several Control

Old forum URL: forums.lhotka.net/forums/t/2376.aspx


akhirudin posted on Monday, February 19, 2007

Hi..

I have a read only object, lets name it PersonList contains(PersonId, JobType, PersonName) with JobType in my CriteriaInfo.
I'm trying to bind this object on the same webform into three webcombo control. 1st combo will contain personlist with jobtype=1, 2nd combo will contain personlist with jobtype=2 and 3rd combo will contain personlist with jobtype=3

I've tried create 3 different csladatasource for each combo, and I send the criteria on it's selectobject event. but it doest work.

can any body help me how to solve this?
I'm using VB
Thanks

PWorthy replied on Tuesday, February 20, 2007

akhirudin
 
You will need to create NameValueListBase Object and create a criteria
 
        [Serializable()]
        public class FilteredCriteria
        {
            private int _jobType;
 
            public int JobType
            {
                get { return _jobType; }
            }      
 
            public FilteredCriteria(int jobtype)
            { 
                _jobtype = jobtype;
            }
 
         }
 
on your dataPortal_Fetch
 
 private void DataPortal_Fetch(FilteredCriteria criteria)
        {
            RaiseListChangedEvents = false;
            IsReadOnly = false;
     
            using (SqlConnection cn = new SqlConnection(Database))
            {
               Call SP to Return data matching criteria.JobType
            }           
            using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
            {
                 while (dr.Read())
                 {
                  Add(new NameValueListBase<string,string>.NameValuePair(dr.Getstring("JobType"),dr.GetString("PersonName"))));
                        }
                    }
                }
            }
            IsReadOnly = true;
            RaiseListChangedEvents = true;
        }
  
 
You can then bind directly to this list object passing in the filter criteria you require. This does mean the BO will go back to the database for every jobtype you ask it to filter on 
          
            PersonList PL = PersonList.GetPersonList(Jobtype1);
            Last5LogRuns.InvalidateCache();
            DDJobtype1.DataSource = PL;
            DDJobtype1.DataTextField = "value";
            DDJobtype1.DataValueField = "key";
            DDJobtype1.DataBind();
 
hope i have understood you correctly and answered your question
 
regards
 
Paul
 
 
 
 
 
 
 

Copyright (c) Marimer LLC