Advertisement
Guest User

Filter control

a guest
May 23rd, 2017
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. using CMS.FormEngine.Web.UI;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Linq;
  8. using CMS.DataEngine;
  9. using CMS.Helpers;
  10. using CMS.DocumentEngine.Web.UI;
  11.  
  12. public partial class CMSModules_Feldmann_Form_Controls_SearchSkuNameSkuNumberFilter : CMSAbstractQueryFilterControl
  13. {
  14.  
  15. /// <summary>
  16. /// Sets up the inner child controls.
  17. /// </summary>
  18. private void SetupControl()
  19. {
  20. // Hides the filter if StopProcessing is enabled
  21. if (this.StopProcessing)
  22. {
  23. this.Visible = false;
  24. }
  25.  
  26. // Initializes only if the current request is NOT a postback
  27. else if (!RequestHelper.IsPostBack())
  28. {
  29.  
  30. }
  31. }
  32.  
  33.  
  34. /// <summary>
  35. /// Generates a WHERE condition and ORDER BY clause based on the current filtering selection.
  36. /// </summary>
  37. private void SetFilter()
  38. {
  39. string where = "";
  40. string order = "";
  41.  
  42. if (!string.IsNullOrWhiteSpace(tbxValue.Text))
  43. {
  44. this.WhereCondition =SqlHelper.AddWhereCondition(this.WhereCondition, string.Format("SkuNumber like '%{0}%'", SqlHelper.EscapeQuotes(tbxValue.Text)));
  45. }
  46.  
  47. // Raises the filter changed event
  48. this.RaiseOnFilterChanged();
  49. }
  50.  
  51. /// <summary>
  52. /// Init event handler.
  53. /// </summary>
  54. protected override void OnInit(EventArgs e)
  55. {
  56. // Creates the child controls
  57. SetupControl();
  58. base.OnInit(e);
  59. }
  60.  
  61. /// <summary>
  62. /// PreRender event handler
  63. /// </summary>
  64. protected override void OnPreRender(EventArgs e)
  65. {
  66. // Checks if the current request is a postback
  67. if (RequestHelper.IsPostBack())
  68. {
  69. // Applies the filter to the displayed data
  70. SetFilter();
  71. }
  72.  
  73. base.OnPreRender(e);
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement