using System; using System.Data; using System.Web; using System.Web.UI.WebControls; using CMS.Controls; using CMS.GlobalHelper; using CMS.PortalControls; public partial class CMSWebParts_WebServices_RepeaterForWebService : CMSAbstractWebPart { #region "Variables" // Transformation name protected string transformationName = ""; #endregion #region "Public properties" /// /// Gets or sets the value that indicates whether to hide control when no data found. /// public bool HideControlForZeroRows { get { return ValidationHelper.GetBoolean(GetValue("HideControlForZeroRows"), basicRepeater.HideControlForZeroRows); } set { SetValue("HideControlForZeroRows", value); basicRepeater.HideControlForZeroRows = value; } } /// /// Gets or sets the text which is displayed when no data found. /// public string ZeroRowsText { get { return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("ZeroRowsText"), basicRepeater.ZeroRowsText), basicRepeater.ZeroRowsText); } set { SetValue("ZeroRowsText", value); basicRepeater.ZeroRowsText = value; } } #endregion #region "Data binding properties" /// /// Gets or sets the value that indicates whether to databind by default. /// public bool DataBindByDefault { get { return ValidationHelper.GetBoolean(GetValue("DataBindByDefault"), basicRepeater.DataBindByDefault); } set { SetValue("DataBindByDefault", value); basicRepeater.DataBindByDefault = value; } } #endregion #region "Webservices properties" /// /// Gets or sets the parameters of the web service. /// public string WebServiceParameters { get { return ValidationHelper.GetString(GetValue("WebServiceParameters"), wsDataSource.WebServiceParameters); } set { SetValue("WebServiceParameters", value); wsDataSource.WebServiceParameters = value; } } /// /// Gets or sets the url of the web service. /// public string WebServiceURL { get { return ValidationHelper.GetString(GetValue("WebServiceURL"), wsDataSource.WebServiceUrl); } set { SetValue("WebServiceURL", value); wsDataSource.WebServiceUrl = value; } } /// /// Gets or sets the name of the transforamtion which is used for displaying the results. /// public string TransformationName { get { return ValidationHelper.GetString(GetValue("TransformationName"), transformationName); } set { SetValue("TransformationName", value); transformationName = value; } } #endregion #region "Stop processing" /// /// Returns true if the control processing should be stopped. /// public override bool StopProcessing { get { return base.StopProcessing; } set { base.StopProcessing = value; wsDataSource.StopProcessing = value; } } #endregion /// /// Content loaded event handler. /// public override void OnContentLoaded() { base.OnContentLoaded(); SetupControl(); } /// /// Initializes the control properties. /// protected void SetupControl() { if (StopProcessing) { basicRepeater.Visible = false; wsDataSource.StopProcessing = true; } else { // Setup the control // Public basicRepeater.HideControlForZeroRows = HideControlForZeroRows; basicRepeater.ZeroRowsText = ZeroRowsText; basicRepeater.DataBindByDefault = DataBindByDefault; // Get web service URL, parameters and transformation name wsDataSource.WebServiceUrl = WebServiceURL; wsDataSource.WebServiceParameters = WebServiceParameters; transformationName = TransformationName; // Connect with data source basicRepeater.DataSource = wsDataSource.DataSource; if (!DataHelper.DataSourceIsEmpty(basicRepeater.DataSource)) { if ((transformationName != null) && (transformationName.Trim() != "")) { // Get url to transformation and load it basicRepeater.ItemTemplate = CMSDataProperties.LoadTransformation(basicRepeater, transformationName, false); } } else { if (HideControlForZeroRows) { Visible = false; } } } } /// /// Reload control's data. /// public override void ReloadData() { base.ReloadData(); SetupControl(); basicRepeater.ReloadData(true); } }