コード例 #1
0
 private void GridSearch()
 {
     try
     {
         lblUserException.Visible = false;
         string txtSearchValue = txtSearch.Text.ToLower();
         int    length         = txtSearchValue.Length;
         try
         {
             if (length >= 3)
             {
                 DAL = new DataAccessLayer();
                 DataTable dtbl     = DAL.GetSearchUsers(ddlSearch.SelectedValue, txtSearch.Text);
                 int       countrow = dtbl.Rows.Count;
                 if (countrow == 0)
                 {
                     lblSearchError.Visible   = true;
                     lblSearchError.Text      = "No Records Found";
                     lblSearchError.ForeColor = System.Drawing.Color.Red;
                     grdViewUsers.Visible     = false;
                     lblUserException.Visible = false;
                 }
                 else
                 {
                     lblSearchError.Visible  = false;
                     grdViewUsers.Visible    = true;
                     grdViewUsers.DataSource = dtbl;
                     grdViewUsers.DataBind();
                 }
             }
             else
             {
                 lblUserErrorMessage.Visible = false;
                 lblSearchError.Visible      = true;
                 lblSearchError.Text         = "Please enter minimum 3 characters";
                 lblSearchError.ForeColor    = System.Drawing.Color.Red;
                 lblUserException.Visible    = false;
             }
         }
         catch (Exception ex)
         {
             lblUserErrorMessage.Visible = false;
             lblUserException.Visible    = true;
             lblUserException.Text       = "Exception Occur in Search: " + ex.Message;
             lblUserException.ForeColor  = System.Drawing.Color.Red;
         }
     }
     catch (Exception ex)
     {
         lblUserException.Visible   = true;
         lblUserException.Text      = "Exception Occur: " + ex.Message;
         lblUserException.ForeColor = System.Drawing.Color.Red;
     }
 }