Example #1
0
    /// <summary>
    /// This method is used when the Administrator clicks the Search button
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void SearchUserButton_Click(object sender, EventArgs e)
    {
        // Assign the search word variable to be used
        string searchWord = SearchUserTextBox.Text.Trim();
        // This regular expression will validate for a alphabet of at least one or more instances and a digit of zero or more instances
        Regex validWord = new Regex("^[a-zA-Z]+[0-9]*");

        // If the searched word is empty; display a message and bind the Administrator Account ODS
        if (string.IsNullOrEmpty(searchWord))
        {
            DisplayFailedMessage("The search field cannot be empty.");
            BindAdministratorAccountODS();
        }
        // If the searched word is more than 100 characters; display a message and bind the Administrator Account ODS
        else if (searchWord.Length > 100)
        {
            DisplayFailedMessage("The search field will only accept 100 characters.");
            BindAdministratorAccountODS();
        }
        // If the searched word does not match the regular expression; display a message and bind the Administrator Account ODS
        else if (!validWord.IsMatch(searchWord))
        {
            DisplayFailedMessage("The search field must start with a letter.");
            BindAdministratorAccountODS();
        }
        // If the searched word passes the regular expression
        else if (validWord.IsMatch(searchWord))
        {
            // Change the DataSourceID to the searched account ODS and bind the list view
            AdministratorAccountListView.DataSourceID = "SearchedAdministratorAccountODS";
            AdministratorAccountListView.DataBind();

            // If there was any results returned; display a message to the Administrator
            if (AdministratorAccountListView.Items.Any())
            {
                DisplaySuccessMessage("Successfully searched for \"" + searchWord + "\"");
            }
            // If there was no results; display a message and bind to the Administrator Account ODS
            else
            {
                DisplayFailedMessage("No results were found for \"" + searchWord + "\"");
                BindAdministratorAccountODS();
            }
        }
        // If there was no results; display a message to the Administrator
        else
        {
            DisplayFailedMessage("No results were found for \"" + searchWord + "\"");
            BindAdministratorAccountODS();
        }
    }
Example #2
0
 /// <summary>
 /// This method is used to bind the list view to the Administrator Account ODS
 /// </summary>
 private void BindAdministratorAccountODS()
 {
     AdministratorAccountListView.DataSourceID = "AdministratorAccountODS";
     AdministratorAccountListView.DataBind();
 }