protected void Submit_Click(object sender, EventArgs e)
        {
            //assume all data is valid
            //the class level List<T> will hold the colletion of data for the page (we have no database)
            //the data collection will be displayed in a table like grid control: GridView

            string fullname       = FullName.Text;
            string emailaddress   = EmailAddress.Text;
            string phonenumber    = PhoneNumber.Text;
            string fullorparttime = FullOrPartTime.SelectedValue;

            //the checkbox list can have several options selected, each option needs to be recorded
            //traverse the options of the control, record each selected option
            //CheckBoxList option are a collection of rows
            //foreach will loop through a collection of rows

            string jobs = "";

            foreach (ListItem jobrow in Jobs.Items)
            {
                if (jobrow.Selected)
                {
                    jobs += jobrow.Text + " ";
                }
                else
                {
                }
            }

            gvCollection.Add(new GridViewData(fullname, emailaddress, phonenumber, fullorparttime, jobs));

            //display the data collection to an appropriate control that will display multiple columns
            JobApplicantList.DataSource = gvCollection;
            JobApplicantList.DataBind();
        }
Exemple #2
0
        protected void Submit_Click(object sender, EventArgs e)
        {
            //assuming for this example, all data is valid
            string fullname       = FullName.Text;
            string emailaddress   = EmailAddress.Text;
            string phonenumber    = PhoneNumber.Text;
            string fullorparttime = FullOrPartTime.SelectedValue;

            //the checkboxlist is a collection of items (rows)
            //we can traverse a collection using a loop: foreach
            //on each row of the collection, you can process its data
            string jobs = "";

            foreach (ListItem jobrow in Jobs.Items)
            {
                if (jobrow.Selected)
                {
                    jobs += jobrow.Text + " ";
                }
            }

            //place the data on the data collection
            gvCollection.Add(new GridViewData(fullname, emailaddress, phonenumber, fullorparttime, jobs));

            //display the collection of data
            //we would like to display the data in a tabular format
            //we will use the gridvierw control to display the tabular format

            JobApplicantList.DataSource = gvCollection;
            JobApplicantList.DataBind();
        }
        protected void Submit_Click(object sender, EventArgs e)
        {
            //assuming for this example, all data is valid - a real application would have validation
            string fullname      = FullName.Text;
            string emailAddress  = EmailAddress.Text;
            string phoneNumber   = PhoneNumber.Text;
            string fullOrPartime = FullOrPartTime.SelectedValue;
            //when dealing with a checkbox list you can get multiple values so .SelectedValue will not work
            //  a foreach loop is more appropriate
            //the checkbox list a collection of items(rows)
            //  we can traverse a collection using a loop: foreach.
            //on each row of the collection, you can process its data
            string jobs = "";

            foreach (ListItem jobRow in Jobs.Items)
            {
                if (jobRow.Selected)
                {
                    jobs += jobRow.Text + " ";
                }
            }
            //place the data on the data collection
            gvCollection.Add(new GridViewData(fullname, emailAddress, phoneNumber, fullOrPartime, jobs));
            //display the collection of data
            // we would like to display the data in a tabular format
            //we will use the GridView control the display the tabular format
            JobApplicantList.DataSource = gvCollection;
            JobApplicantList.DataBind();
        }
        protected void Submit_Click(object sender, EventArgs e)
        {
            //Assume all data is valid.
            //The class level List<T> will hold the collection of data for the page (we have no db).
            //The data collection will be displayed in a table-like grid control (tabular): GridView.

            string fullname       = FullName.Text;
            string emailaddress   = EmailAddress.Text;
            string phonenumber    = PhoneNumber.Text;
            string fullorparttime = FullOrPartTime.Text;

            //The checkbox list can have several options selected. Each option needs to be recorded.
            //Traverse the options of the control, record each selected option.
            //CheckBoxList option are a collection of rows.
            //foreach will loop thru a collection of rows.

            string jobs = "";

            foreach (ListItem jobrow in Jobs.Items)
            {
                if (jobrow.Selected)
                {
                    jobs += jobrow.Text + " ";
                }
            }

            gvCollection.Add(new GridViewData(fullname, emailaddress, phonenumber, fullorparttime, jobs));

            //Display the data collection to an appropriate control that will display multiple columns
            //A dropdown list won't have enough rows, so we need to use a WebGrid called a GridView.
            JobApplicantList.DataSource = gvCollection;
            JobApplicantList.DataBind();
        }
 protected void Clear_Click(object sender, EventArgs e)
 {
     FullName.Text                = "";
     EmailAddress.Text            = "";
     PhoneNumber.Text             = "";
     FullOrPartTime.SelectedIndex = -1; //Invalid so it prevents anything from turning on. Or use:
     //FullOrPartTime.ClearSelection();
     //Jobs.SelectedIndex = -1;
     Jobs.ClearSelection();
     JobApplicantList.DataSource = null;
     JobApplicantList.DataBind();
 }
Exemple #6
0
        protected void Clear_Click(object sender, EventArgs e)
        {
            FullName.Text                = "";
            EmailAddress.Text            = "";
            PhoneNumber.Text             = "";
            FullOrPartTime.SelectedIndex = -1;
            // or FullOrPartTime.ClearSelection();
            // Jobs.SelectedIndex = -1;
            Jobs.ClearSelection();

            JobApplicantList.DataSource = null;
            JobApplicantList.DataBind();
        }