Postback Issue in custom webpart.

5 posts, 0 answers
  1. Martin Vesely
    Martin Vesely avatar
    10 posts
    Member since:
    May 2009

    Posted 11 Jan 2010 Link to this post

    Hello,
    I am creating a custom webpart using telerik combobox . And i have used Radajaxmanager to avoid postback on the selectedindexchanged event of the combobox.But when i run the webpart this event works fine but postback happens in the first attempt.But from second attempt onwards ajax works. Please tell me the solution to avoid this postback in the first attempt of change event of combobox.

    Please find the below code  for your reference.


       protected override void CreateChildControls()
            {
                base.CreateChildControls();
                try
                {
                    _panel = new Panel();
                    _panel.ID = "panel";

                    _tblSearch = new Table();
                    _tblSearch.ID = "TblSearchCriteria";
                    _tblSearch.CssClass = "ms-formtable";
                    _tblSearch.Attributes.Add("border", "0");
                    _tblSearch.Attributes.Add("width", "100%");
                    _tblSearch.CellPadding = 0;
                    _tblSearch.CellSpacing = 0;
                    _tblSearch.Style.Add("margin-top", "8");



             _cobSearchCriteria = new RadComboBox();
                    _cobSearchCriteria.ID = "cobSearchCriteria";
                    _cobSearchCriteria.Width = Unit.Pixel(500);
                    _cobSearchCriteria.Skin = "WebBlue";
                    _cobSearchCriteria.MarkFirstMatch = false;
                    _cobSearchCriteria.AutoPostBack = true;
                    _cobSearchCriteria.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(_cobSearchCriteria_SelectedIndexChanged);

            _tblSearch.Controls.Add(_cobSearchCriteria);

            _panel.Controls.Add(_tblSearch);


                  am = new RadAjaxManager();
                        am.ID = "RadAjaxManager1";
                        Controls.Add(am);
                        Page.Items.Add(typeof(RadAjaxManager), am);
                        lp = new RadAjaxLoadingPanel();
                        lp.ID = "RadAjaxLoadingPanel1";
                        //  lp.IsSticky = true; Check this property for the position of Loading Panel..
                        Controls.Add(lp);
                        lp.Transparency = 50;

                        img = new System.Web.UI.WebControls.Image();
                        img.ID = "Image1";
                        lp.Controls.Add(img);
                        img.AlternateText = "Loading...";
                        img.ImageUrl = RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif");
                        img.Style.Add("border", "0px");

                        am.DefaultLoadingPanelID = lp.ID;

                        // Adding Controls to RadAjax Manager
                        am.AjaxSettings.AddAjaxSetting(_cobPredPrijemce, _panel);
                        // Done Adding Controls to RadAjax Manager


        }


    protected void _cobPredPrijemce_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
            {
                // throw new NotImplementedException();
                //am.AjaxSettings.AddAjaxSetting(_cobPredPrijemce, _panel);
                _tblUpdate.Visible = true;
                _tblFyzická.Visible = false;
                _tblPodnikající.Visible = false;
                _tblOVM.Visible = false;
                _tblPrávnická.Visible = false;
                _tblSearch.Visible = true;

            }


    Kindly revert asap. Thanking you in Advance.

    Regards,
    Martin

  2. Rosen
    Admin
    Rosen avatar
    3237 posts

    Posted 11 Jan 2010 Link to this post

    Hi Martin,

    Can you please move the RadAjaxManager initialization code to the WebPart's Init event and see if there is any change in the observed behavior.

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        am = new RadAjaxManager();
        am.ID = "RadAjaxManager1";
        Controls.Add(am);
        Page.Items.Add(typeof(RadAjaxManager), am);        
    }

    Greetings,
    Rosen
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

  3. Martin Vesely
    Martin Vesely avatar
    10 posts
    Member since:
    May 2009

    Posted 11 Jan 2010 Link to this post

    Hi Rosen,
    I tried changing the code according to your instructions. But still no change....
    Please find below the required code.


    using System;
    using System.Runtime.InteropServices;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Xml.Serialization;
    using System.ComponentModel;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.WebControls;
    using Microsoft.SharePoint.WebPartPages;
    using Telerik.Web.UI;
    using System.Data;
    using Microsoft.SharePoint.Administration;
    using TechniServIT.DS.Library;
    using System.Collections;
    using System.Collections.Generic;
    using System.Drawing;
    namespace DemoTelerikcontrol
    {
        [Guid("533de230-42ed-4ecb-b430-7ad0563fcdc1")]



        public class DemoTelerikcontrol : System.Web.UI.WebControls.WebParts.WebPart
        {
            static string LoginName1; //= ConfigurationSettings.AppSettings["LoginName1"]; // zde je treba doplnit prihlasovaci jmeno k prvni schrance
            static string Password1; // = ConfigurationSettings.AppSettings["Password1"]; //zde je treba doplnit heslo k prvni schrance
            static string Certificate1; // = ConfigurationSettings.AppSettings["Certificate1"]; // zde je třeba doplnit uplne jmeno souboru s certifikatem pro pristup k prvni schrance
            
            # region "Global Variable Declarations"
            
           
            private Panel _panel;
            private Label _lblSchránky;
            private Label _lblPříjemce;
            private Label _lblSearch;
            private Label _lblIDSchránky;
            private Label _lblJméno;
            private Label _lblPříjmení;
            private Label _lblDatum;
            private Label _lblObec;
            private Label _lblUlice;
            private Label _lblpopisné;
            private Label _lblorientační;
            private Label _lbl1Errors;

            private Label _lblPodIDSchránky;
            private Label _lblPodIČ;
            private Label _lblPodJméno;
            private Label _lblPodPříjmení;
            private Label _lblPodObec;
            private Label _lblPodUlice;
            private Label _lblPodpopisné;
            private Label _lblPodorientační;
            private Label _lbl2Errors;

            private Label _lblPráIDSchránky;
            private Label _lblPráIČ;
            private Label _lblPráNázev;
            private Label _lbl3Errors;


            private Label _lblOVMIDSchránky;
            private Label _lblOVMIČ;
            private Label _lblOVMNázev;
            private Label _lbl4Errors;
            protected Label lblblank;


            private RadTextBox _txb1Ulice;
            private RadTextBox _txb1Obec;
            private RadTextBox _txb1IDSchranky;
            private RadTextBox _txb1Jmeno;
            private RadTextBox _txb1Prijmeni;
            private RadMaskedTextBox _txb1DatumNarozeni;
            private RadTextBox _txb1CisloPopisne;
            private RadTextBox _txb1CisloOrientacni;
            private RadComboBox _cobOdesilatel;
            private RadComboBox _cobPredPrijemce;
            private RadComboBox _cobSearchCriteria;

            private RadTextBox _txb2UliceMistaPodnikani;
            private RadTextBox _txb2ObecMistaPodnikani;
            private RadTextBox _txb2IDSchranky;
            private RadTextBox _txb2Jmeno;
            private RadTextBox _txb2Prijmeni;
            private RadTextBox _txb2IC;
            private RadTextBox _txb2CisloPopisne;
            private RadTextBox _txb2CisloOrientacni;

            private RadTextBox _txb3IDSchranky;
            private RadTextBox _txb3IC;
            private RadTextBox _txb3NazevOrganizace;

            private RadTextBox _txb4IDSchranky;
            private RadTextBox _txb4IC;
            private RadTextBox _txb4Nazevorganizace;


            private Button _btn1Search;
            private Button _btn2Search;
            private Button _btn3Search;
            private Button _btn4Search;
            private RadGrid _radGrid1;
            private Table _tblSearch;
            private Table _tblFyzická;
            private Table _tblPodnikající;
            private Table _tblPrávnická;
            private Table _tblOVM;
            private Table _tblUpdate;
            private Table _tblDataGrid;
            // For update screen
            private Label _lblSaveError;
            private Label _lblSaveSuccess;
            private Label _lblnázev;
            private Label _lblVěc;
            private Label _lblSkartačnísymbol;
            private Label _lblNašeč;
            private Label _lblNašesp;
            private Label _lblVašeč;
            private Label _lblVašesp;
            private Label _lblKrukám;
            private Label _lblDovlastníchrukou;
            private Label _lblZákazdoručenífikcí;
            private Label _lblZmocněníčíslo;
            private Label _lblZmocněnírok;
            private Label _lblZmocněníParagraf;
            private Label _lblZmocněníodstavec;
            private Label _lblZmocněnípísmeno;
            private Label _lblPoznámka;
            private Label _lblPřílohy;
            private RadTextBox _txbNazev;
            private RadTextBox _txbVec;
            private RadTextBox _txbNasecj;
            private RadTextBox _txbNaseSpZn;
            private RadTextBox _txbVasecj;
            private RadTextBox _txbVaseSpZn;
            private RadTextBox _txbKRukam;
            private RadTextBox _txbCisloZakona;
            private RadTextBox _txbRokVydani;
            private RadTextBox _txbParagrafVZakone;
            private RadTextBox _txbOdstavecParagrafu;
            private RadTextBox _txbPismeniVOdstavci;
            private RadTextBox _txbPoznamka;
            private Button _btnSave;
            private Button _btnSend;
            private CheckBox _chbPredPrijemce;
            private CheckBox _chbDoVlastnichRukou;
            private CheckBox _chbZakazDoruceniFikci;
            private RadUpload _RadUpload1;

            private RadComboBox _cobSkartacniSymbol;

            // finished update screen
            protected RadioButtonList rdOptions;
            protected RadAjaxManager am;
            protected RadAjaxLoadingPanel lp;
            protected System.Web.UI.WebControls.Image img;
            protected System.Web.UI.WebControls.Image imgdatave;
            protected System.Web.UI.WebControls.Image imgLogo;
            private string _listNastaveni = "Nastavení";
            private string _listAdresar = "Adresář";
            private string _itemIDDS = "IDDS";
            private string _webUrl = "/ds";
            private string _siet = "http://wsstest:2222";
            private string _WebServiceUserAgent = "602";
            private string _Proxydomain = "http://192.168.1.25:3128";
            private string _ProxyLogin = "Techniserv\\dmssupport";
            private string _ProxyPass = "Passw0rd987";
            private string _UseProxy = "false";
            private string _BaseUri = "www.czebox.cz";
            SPWeb oWebSite;

            #endregion

            #region "User Defined Properties"
            [WebBrowsable(true), Personalizable(true), Browsable(true), Category("Nastavení"), WebPartStorage(Storage.Shared),
           FriendlyName("ConfigurationXml"), Description("Configuration")]
            public string listNastaveni
            {
                get { return _listNastaveni; }
                set { _listNastaveni = value; }
            }
            [WebBrowsable(true), Personalizable(true), Browsable(true), Category("listAdresar"), WebPartStorage(Storage.Shared),
            FriendlyName("ConfigurationXml"), Description("Configuration")]
            public string listAdresar
            {
                get { return _listAdresar; }
                set { _listAdresar = value; }
            }

            [WebBrowsable(true), Personalizable(true), Browsable(true), Category("IDDS"), WebPartStorage(Storage.Shared),
            FriendlyName("ConfigurationXml"), Description("Configuration")]
            public string itemIDDS
            {
                get { return _itemIDDS; }
                set { _itemIDDS = value; }
            }

            [WebBrowsable(true), Personalizable(true), Browsable(true), Category("webUrl"), WebPartStorage(Storage.Shared),
          FriendlyName("ConfigurationXml"), Description("Configuration")]
            public string webUrl
            {
                get { return _webUrl; }
                set { _webUrl = value; }
            }


            [WebBrowsable(true), Personalizable(true), Browsable(true), Category("siet"), WebPartStorage(Storage.Shared),
                   FriendlyName("ConfigurationXml"), Description("Configuration")]
            public string siet
            {
                get { return _siet; }
                set { _siet = value; }
            }


            [WebBrowsable(true), Personalizable(true), Browsable(true), Category("UserAgent"), WebPartStorage(Storage.Shared),
           FriendlyName("ConfigurationXml"), Description("Configuration")]
            public string WebServiceUserAgent
            {
                get { return _WebServiceUserAgent; }
                set { _WebServiceUserAgent = value; }
            }



            [WebBrowsable(true), Personalizable(true), Browsable(true), Category("Proxydomain"), WebPartStorage(Storage.Shared),
           FriendlyName("ConfigurationXml"), Description("Configuration")]
            public string Proxydomain
            {
                get { return _Proxydomain; }
                set { _Proxydomain = value; }
            }

            [WebBrowsable(true), Personalizable(true), Browsable(true), Category("ProxyLogin"), WebPartStorage(Storage.Shared),
           FriendlyName("ConfigurationXml"), Description("Configuration")]
            public string ProxyLogin
            {
                get { return _ProxyLogin; }
                set { _ProxyLogin = value; }

            }

            [WebBrowsable(true), Personalizable(true), Browsable(true), Category("ProxyPass"), WebPartStorage(Storage.Shared),
           FriendlyName("ConfigurationXml"), Description("Configuration")]
            public string ProxyPass
            {
                get { return _ProxyPass; }
                set { _ProxyPass = value; }
            }

            [WebBrowsable(true), Personalizable(true), Browsable(true), Category("UseProxy"), WebPartStorage(Storage.Shared),
           FriendlyName("ConfigurationXml"), Description("Configuration")]
            public string UseProxy
            {
                get { return _UseProxy; }
                set { _UseProxy = value; }
            }

            [WebBrowsable(true), Personalizable(true), Browsable(true), Category("BaseUri"), WebPartStorage(Storage.Shared),
           FriendlyName("ConfigurationXml"), Description("Configuration")]
            public string BaseUri
            {
                get { return _BaseUri; }
                set { _BaseUri = value; }
            }

            #endregion

            protected override void OnInit(EventArgs e)
            {
                base.OnInit(e);
                am = new RadAjaxManager();
                am.ID = "RadAjaxManager1";
                Controls.Add(am);
                Page.Items.Add(typeof(RadAjaxManager), am);
            }

            protected override void OnLoad(EventArgs e)
            {

                base.OnInit(e);
                Page.ClientScript.RegisterStartupScript(typeof(DemoTelerikcontrol), this.ID, "_spOriginalFormAction = document.forms[0].action;_spSuppressFormOnSubmitWrapper=true;", true);
                if (this.Page.Form != null)
                {
                    string formOnSubmitAtt = this.Page.Form.Attributes["onsubmit"];
                    if (!string.IsNullOrEmpty(formOnSubmitAtt) && formOnSubmitAtt == "return _spFormOnSubmitWrapper();")
                    {
                        this.Page.Form.Attributes["onsubmit"] = "_spFormOnSubmitWrapper();";
                    }
                }

             

            }
            protected override void CreateChildControls()
            {
                base.CreateChildControls();
                try
                {
                    _panel = new Panel();
                    _panel.ID = "panel";

                    _tblSearch = new Table();
                    _tblSearch.ID = "TblSearchCriteria";
                    _tblSearch.CssClass = "ms-formtable";
                    _tblSearch.Attributes.Add("border", "0");
                    _tblSearch.Attributes.Add("width", "100%");
                    _tblSearch.CellPadding = 0;
                    _tblSearch.CellSpacing = 0;
                    _tblSearch.Style.Add("margin-top", "8");

                    _tblFyzická = new Table();
                    _tblFyzická.ID = "TblFyzická";
                    _tblFyzická.CssClass = "ms-formtable";
                    _tblFyzická.Attributes.Add("border", "0");
                    _tblFyzická.Attributes.Add("width", "100%");
                    _tblFyzická.Attributes.Add("Title", "Search");
                    _tblFyzická.CellPadding = 0;
                    _tblFyzická.CellSpacing = 0;
                    _tblFyzická.Style.Add("margin-top", "8");


                    _tblPodnikající = new Table();
                    _tblPodnikající.ID = "TblPodnikající";
                    _tblPodnikající.CssClass = "ms-formtable";
                    _tblPodnikající.Attributes.Add("border", "0");
                    _tblPodnikající.Attributes.Add("width", "100%");
                    _tblPodnikající.CellPadding = 0;
                    _tblPodnikající.CellSpacing = 0;
                    _tblPodnikající.Style.Add("margin-top", "8");

                    _tblPrávnická = new Table();
                    _tblPrávnická.ID = "TblPrávnická";
                    _tblPrávnická.CssClass = "ms-formtable";
                    _tblPrávnická.Attributes.Add("border", "0");
                    _tblPrávnická.Attributes.Add("width", "100%");
                    _tblPrávnická.CellPadding = 0;
                    _tblPrávnická.CellSpacing = 0;
                    _tblPrávnická.Style.Add("margin-top", "8");

                    _tblOVM = new Table();
                    _tblOVM.ID = "TblOVM";
                    _tblOVM.CssClass = "ms-formtable";
                    _tblOVM.Attributes.Add("border", "0");
                    _tblOVM.Attributes.Add("width", "100%");
                    _tblOVM.CellPadding = 0;
                    _tblOVM.CellSpacing = 0;
                    _tblOVM.Style.Add("margin-top", "8");

                    _tblUpdate = new Table();
                    _tblUpdate.ID = "TblUpdate";
                    _tblUpdate.CssClass = "ms-formtable";
                    _tblUpdate.Attributes.Add("border", "0");
                    _tblUpdate.Attributes.Add("width", "100%");
                    _tblUpdate.CellPadding = 0;
                    _tblUpdate.CellSpacing = 0;
                    _tblUpdate.Style.Add("margin-top", "8");

                    _tblDataGrid = new Table();
                    _tblDataGrid.ID = "TblDataGrid";
                    _tblDataGrid.CssClass = "ms-formtable";
                    _tblDataGrid.Attributes.Add("border", "0");
                    _tblDataGrid.Attributes.Add("width", "100%");
                    _tblDataGrid.CellPadding = 0;
                    _tblDataGrid.CellSpacing = 0;
                    _tblDataGrid.Style.Add("margin-top", "8");

                    _lblSchránky = new Label();
                    _lblSchránky.ID = "lblSchránky";
                    _lblSchránky.Text = "Odeslat z datové schránky";

                    _chbPredPrijemce = new CheckBox();
                    _chbPredPrijemce.ID = "chbPredPrijemce";
                    _chbPredPrijemce.Text = "Předdefinovaný příjemce";
                    _lblSearch = new Label();
                    _lblSearch.ID = "lblSearch";
                    _lblSearch.Text = "Typ Schránky ";

                    _cobOdesilatel = new RadComboBox();
                    _cobOdesilatel.ID = "cobOdesilatel";
                    _cobOdesilatel.Width = Unit.Pixel(500);
                    _cobOdesilatel.Skin = "WebBlue";
                    _cobOdesilatel.MarkFirstMatch = false;
                    _cobOdesilatel.EmptyMessage = "Odesílatel";
                    _cobPredPrijemce = new RadComboBox();
                    _cobPredPrijemce.ID = "cobPredPrijemce";
                    _cobPredPrijemce.Width = Unit.Pixel(500);
                    _cobPredPrijemce.Skin = "WebBlue";
                    _cobPredPrijemce.MarkFirstMatch = false;
                    _cobPredPrijemce.EmptyMessage = "Vyberte příjemce";
                    _cobPredPrijemce.AutoPostBack = true;
                    _cobPredPrijemce.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(_cobPredPrijemce_SelectedIndexChanged);
                    _cobSearchCriteria = new RadComboBox();
                    _cobSearchCriteria.ID = "cobSearchCriteria";
                    _cobSearchCriteria.Width = Unit.Pixel(500);
                    _cobSearchCriteria.Skin = "WebBlue";
                    _cobSearchCriteria.MarkFirstMatch = false;
                    _cobSearchCriteria.AutoPostBack = true;
                    _cobSearchCriteria.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(_cobSearchCriteria_SelectedIndexChanged);

                    // Table 1 controls
                    _lbl1Errors = new Label();
                    _lbl1Errors.ID = "lbl1Errors";
                    _lbl1Errors.ForeColor = Color.Red;
                    _lblIDSchránky = new Label();
                    _lblIDSchránky.ID = "lblIDSchránky";
                    _lblIDSchránky.Text = "ID Schránky";
                    _lblJméno = new Label();
                    _lblJméno.ID = "lblJméno";
                    _lblJméno.Text = "Jméno";
                    _lblPříjmení = new Label();
                    _lblPříjmení.ID = "lblPříjmení";
                    _lblPříjmení.Text = "Příjmení";
                    _lblDatum = new Label();
                    _lblDatum.ID = "lblDatum";
                    _lblDatum.Text = "Datum narození";
                    _lblObec = new Label();
                    _lblObec.ID = "lblObec";
                    _lblObec.Text = "Obec";
                    _lblUlice = new Label();
                    _lblUlice.ID = "lblUlice";
                    _lblUlice.Text = "Ulice";
                    _lblpopisné = new Label();
                    _lblpopisné.ID = "lblpopisné";
                    _lblpopisné.Text = "Číslo popisné";
                    _lblorientační = new Label();
                    _lblorientační.ID = "lblorientační";
                    _lblorientační.Text = "Číslo orientační";
                    _txb1IDSchranky = new RadTextBox();
                    _txb1IDSchranky.ID = "txb1IDSchranky";
                    _txb1IDSchranky.Width = Unit.Pixel(500);
                    _txb1IDSchranky.EmptyMessage = "ID Schránky";
                    _txb1IDSchranky.MaxLength = 7;
                    _txb1Jmeno = new RadTextBox();
                    _txb1Jmeno.ID = "txb1Jmeno";
                    _txb1Jmeno.Width = Unit.Pixel(500);
                    _txb1Jmeno.EmptyMessage = "Jméno";
                    _txb1Prijmeni = new RadTextBox();
                    _txb1Prijmeni.ID = "txb1Prijmeni";
                    _txb1Prijmeni.Width = Unit.Pixel(500);
                    _txb1Prijmeni.EmptyMessage = "Přijmení";
                    _txb1DatumNarozeni = new RadMaskedTextBox();
                    _txb1DatumNarozeni.ID = "txb1DatumNarozeni";
                    _txb1DatumNarozeni.Width = Unit.Pixel(500);
                    _txb1DatumNarozeni.Mask = "<0..31>.<0..12>.<0..9999>";
                    _txb1DatumNarozeni.PromptChar = "_";
                    _txb1Obec = new RadTextBox();
                    _txb1Obec.ID = "txb1Obec";
                    _txb1Obec.Width = Unit.Pixel(500);
                    _txb1Obec.EmptyMessage = "Obec";
                    _txb1Ulice = new RadTextBox();
                    _txb1Ulice.ID = "txb1Ulice";
                    _txb1Ulice.Width = Unit.Pixel(500);
                    _txb1Ulice.EmptyMessage = "Ulice";
                    _txb1CisloPopisne = new RadTextBox();
                    _txb1CisloPopisne.ID = "txb1CisloPopisne";
                    _txb1CisloPopisne.Width = Unit.Pixel(500);
                    _txb1CisloPopisne.EmptyMessage = "Číslo popisné";
                    _txb1CisloOrientacni = new RadTextBox();
                    _txb1CisloOrientacni.ID = "txb1CisloOrientacni";
                    _txb1CisloOrientacni.Width = Unit.Pixel(500);
                    _txb1CisloOrientacni.EmptyMessage = "Číslo orientační";
                    _btn1Search = new Button();
                    _btn1Search.Text = "Vyhledat";
                    _btn1Search.ID = "btn1Search";
                    _btn1Search.CssClass = "UserButton";


                    _btn1Search.Click += new EventHandler(_btn1Search_Click);
                    _radGrid1 = new RadGrid();
                    _radGrid1.ID = "radGrid1";
                    _radGrid1.PageSize = 20;
                    _radGrid1.AllowPaging = true;
                    _radGrid1.AllowSorting = true;
                    _radGrid1.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;
                    _radGrid1.Skin = "WebBlue";
                    //End Table 1 Controls


                    // Table 2 Controls
                    _lbl2Errors = new Label();
                    _lbl2Errors.ID = "lbl2Errors";
                    _lbl2Errors.ForeColor = Color.Red;
                    _lblPodIDSchránky = new Label();
                    _lblPodIDSchránky.ID = "lblPodIDSchránky";
                    _lblPodIDSchránky.Text = "ID Schránky";
                    _lblPodJméno = new Label();
                    _lblPodJméno.ID = "lblPodJméno";
                    _lblPodJméno.Text = "Jméno";
                    _lblPodPříjmení = new Label();
                    _lblPodPříjmení.ID = "lblPodPříjmení";
                    _lblPodPříjmení.Text = "Příjmení";
                    _lblPodIČ = new Label();
                    _lblPodIČ.ID = "lblPodIČ";
                    _lblPodIČ.Text = "Identifikační číslo ";
                    _lblPodObec = new Label();
                    _lblPodObec.ID = "lblPodObec";
                    _lblPodObec.Text = "Obec místa podnikání";
                    _lblPodUlice = new Label();
                    _lblPodUlice.ID = "lblPodUlice";
                    _lblPodUlice.Text = "Ulice místa podnikání";
                    _lblPodpopisné = new Label();
                    _lblPodpopisné.ID = "lblPodpopisné";
                    _lblPodpopisné.Text = "Číslo popisné";
                    _lblPodorientační = new Label();
                    _lblPodorientační.ID = "lblPodorientační";
                    _lblPodorientační.Text = "Číslo orientační";

                    _txb2IDSchranky = new RadTextBox();
                    _txb2IDSchranky.ID = "txb2IDSchranky";
                    _txb2IDSchranky.Width = Unit.Pixel(500);
                    _txb2IDSchranky.EmptyMessage = "ID Schránky";
                    _txb2IDSchranky.MaxLength = 7;
                    _txb2IC = new RadTextBox();
                    _txb2IC.ID = "txb2IC";
                    _txb2IC.Width = Unit.Pixel(500);
                    _txb2IC.EmptyMessage = "Identifikační číslo";
                    _txb2Jmeno = new RadTextBox();
                    _txb2Jmeno.ID = "txb2Jmeno";
                    _txb2Jmeno.Width = Unit.Pixel(500);
                    _txb2Jmeno.EmptyMessage = "Jméno";
                    _txb2Prijmeni = new RadTextBox();
                    _txb2Prijmeni.ID = "txb2Prijmeni";
                    _txb2Prijmeni.Width = Unit.Pixel(500);
                    _txb2Prijmeni.EmptyMessage = "Přijmení";
                    _txb2ObecMistaPodnikani = new RadTextBox();
                    _txb2ObecMistaPodnikani.ID = "txb2Obec";
                    _txb2ObecMistaPodnikani.Width = Unit.Pixel(500);
                    _txb2ObecMistaPodnikani.EmptyMessage = "Obec místa podnikání";
                    _txb2UliceMistaPodnikani = new RadTextBox();
                    _txb2UliceMistaPodnikani.ID = "txb2UliceMistaPodnikani";
                    _txb2UliceMistaPodnikani.Width = Unit.Pixel(500);
                    _txb2UliceMistaPodnikani.EmptyMessage = " Ulice místa podnikání";
                    _txb2CisloPopisne = new RadTextBox();
                    _txb2CisloPopisne.ID = "txb2CisloPopisne";
                    _txb2CisloPopisne.Width = Unit.Pixel(500);
                    _txb2CisloPopisne.EmptyMessage = "Číslo popisné";
                    _txb2CisloOrientacni = new RadTextBox();
                    _txb2CisloOrientacni.ID = "txb2CisloOrientacni";
                    _txb2CisloOrientacni.Width = Unit.Pixel(500);
                    _txb2CisloOrientacni.EmptyMessage = "Číslo orientační";
                    _btn2Search = new Button();
                    _btn2Search.Text = "Vyhledat";
                    _btn2Search.ID = "btn2Search";
                    _btn2Search.Click += new EventHandler(_btn2Search_Click);

                    // End Table 2 Controls

                    // Table 3 Controls
                    _lblPráIDSchránky = new Label();
                    _lblPráIDSchránky.ID = "lblPráIDSchránky";
                    _lblPráIDSchránky.Text = "ID Schránky";

                    _lblPráIČ = new Label();
                    _lblPráIČ.ID = "lblPráIČ";
                    _lblPráIČ.Text = "Identifikační číslo";

                    _lblPráNázev = new Label();
                    _lblPráNázev.ID = "lblPráNázev";
                    _lblPráNázev.Text = " Název organizace";

                    _lbl3Errors = new Label();
                    _lbl3Errors.ID = "lbl3Errors";
                    _lbl3Errors.ForeColor = Color.Red;
                    //_lbl3Errors.Visible = false;

                    _txb3IDSchranky = new RadTextBox();
                    _txb3IDSchranky.ID = "txb3IDSchranky";
                    _txb3IDSchranky.Width = Unit.Pixel(500);
                    _txb3IDSchranky.EmptyMessage = "ID Schránky";


                    _txb3IC = new RadTextBox();
                    _txb3IC.ID = "txb3IC";
                    _txb3IC.Width = Unit.Pixel(500);
                    _txb3IC.EmptyMessage = "Identifikační číslo";

                    _txb3NazevOrganizace = new RadTextBox();
                    _txb3NazevOrganizace.ID = "txb3NazevOrganizace";
                    _txb3NazevOrganizace.Width = Unit.Pixel(500);
                    _txb3NazevOrganizace.EmptyMessage = "Název organizace";

                    _btn3Search = new Button();
                    _btn3Search.ID = "btn3Search";
                    _btn3Search.Text = "Vyhledat";
                    _btn3Search.ID = "btn3Search";
                    _btn3Search.Click += new EventHandler(_btn3Search_Click);

                    // End Table 3 Controls


                    // Table 4 Controls
                    _lblOVMIDSchránky = new Label();
                    _lblOVMIDSchránky.ID = "lblOVMIDSchránky";
                    _lblOVMIDSchránky.Text = "ID Schránky";

                    _lblOVMIČ = new Label();
                    _lblOVMIČ.ID = "lblOVMIČ";
                    _lblOVMIČ.Text = "Identifikační číslo";

                    _lblOVMNázev = new Label();
                    _lblOVMNázev.ID = "lblOVMNázev";
                    _lblOVMNázev.Text = "Název organizace";

                    _lbl4Errors = new Label();
                    _lbl4Errors.ID = "lbl4Errors";
                    _lbl4Errors.ForeColor = Color.Red;

                    _txb4IDSchranky = new RadTextBox();
                    _txb4IDSchranky.ID = "txb4IDSchranky";
                    _txb4IDSchranky.Width = Unit.Pixel(500);
                    _txb4IDSchranky.EmptyMessage = "ID Schránky";

                    _txb4IC = new RadTextBox();
                    _txb4IC.ID = "txb4IC";
                    _txb4IC.Width = Unit.Pixel(500);
                    _txb4IC.EmptyMessage = "Identifikační číslo";

                    _txb4Nazevorganizace = new RadTextBox();
                    _txb4Nazevorganizace.ID = "txb4Nazevorganizace";
                    _txb4Nazevorganizace.Width = Unit.Pixel(500);
                    _txb4Nazevorganizace.EmptyMessage = "Název organizace";

                    _btn4Search = new Button();
                    _btn4Search.ID = "btn4Search";
                    _btn4Search.Text = "Vyhledat";
                    _btn4Search.ID = "btn4Search";
                    _btn4Search.Click += new EventHandler(_btn4Search_Click);

                    // End Table 4 Controls


                    // Table 5 controls
                    _lblSaveError = new Label();
                    _lblSaveError.ID = "lblSaveError"; // To define style for this later
                    _lblSaveError.ForeColor = Color.Red;
                    _lblSaveSuccess = new Label();
                    _lblSaveSuccess.ID = "lblSaveSuccess";
                    _lblSaveSuccess.ForeColor = Color.Red;
                    _lblnázev = new Label();
                    _lblnázev.ID = "lblnázev";
                    _lblnázev.Text = "Interní název";
                    _txbNazev = new RadTextBox();
                    _txbNazev.ID = "txbNazev";
                    _txbNazev.Width = Unit.Pixel(500);
                    _txbNazev.TextMode = InputMode.SingleLine;
                    _txbNazev.Skin = "WebBlue";
                    _lblVěc = new Label();
                    _lblVěc.ID = "lblVěc";
                    _lblVěc.Text = "Věc";
                    _txbVec = new RadTextBox();
                    _txbVec.ID = "txbVec";
                    _txbVec.Width = Unit.Pixel(500);
                    _txbVec.TextMode = InputMode.SingleLine;
                    _txbVec.Skin = "WebBlue";
                    _lblSkartačnísymbol = new Label();
                    _lblSkartačnísymbol.ID = "lblSkartačnísymbol";
                    _lblSkartačnísymbol.Text = "Skartační symbol";
                    _cobSkartacniSymbol = new RadComboBox();
                    _cobSkartacniSymbol.ID = "cobSkartacniSymbol";
                    _cobSkartacniSymbol.EmptyMessage = "Skartační symbol";
                    _cobSkartacniSymbol.MarkFirstMatch = false;
                    _cobSkartacniSymbol.Skin = "WebBlue";
                    _cobSkartacniSymbol.Width = Unit.Pixel(500);
                    _lblNašeč = new Label();
                    _lblNašeč.ID = "lblNašeč";
                    _lblNašeč.Text = "Naše č.j.";
                    _txbNasecj = new RadTextBox();
                    _txbNasecj.ID = "txbNasecj";
                    _txbNasecj.Width = Unit.Pixel(500);
                    _txbNasecj.Skin = "WebBlue";
                    _txbNasecj.TextMode = InputMode.SingleLine;
                    _lblNašesp = new Label();
                    _lblNašesp.ID = "lblNašesp";
                    _lblNašesp.Text = "Naše sp. Zn.";
                    _txbNaseSpZn = new RadTextBox();
                    _txbNaseSpZn.ID = "txbNaseSpZn";
                    _txbNaseSpZn.Width = Unit.Pixel(500);
                    _txbNaseSpZn.TextMode = InputMode.SingleLine;
                    _txbNaseSpZn.Skin = "WebBlue";
                    _lblVašeč = new Label();
                    _lblVašeč.ID = "lblVašeč";
                    _lblVašeč.Text = "Vaše č.j.";
                    _txbVasecj = new RadTextBox();
                    _txbVasecj.ID = "txbVasecj";
                    _txbVasecj.Width = Unit.Pixel(500);
                    _txbVasecj.Skin = "WebBlue";
                    _txbVasecj.TextMode = InputMode.SingleLine;
                    _lblVašesp = new Label();
                    _lblVašesp.ID = "lblVašesp";
                    _lblVašesp.Text = "Vaše sp. Zn.";
                    _txbVaseSpZn = new RadTextBox();
                    _txbVaseSpZn.ID = "txbVaseSpZn";
                    _txbVaseSpZn.Width = Unit.Pixel(500);
                    _txbVaseSpZn.TextMode = InputMode.SingleLine;
                    _lblKrukám = new Label();
                    _lblKrukám.ID = "lblKrukám";
                    _lblKrukám.Text = "K rukám";
                    _txbKRukam = new RadTextBox();
                    _txbKRukam.ID = "txbKRukam";
                    _txbKRukam.Width = Unit.Pixel(500);
                    _txbKRukam.Skin = "WebBlue";
                    _txbKRukam.TextMode = InputMode.SingleLine;
                    _lblDovlastníchrukou = new Label();
                    _lblDovlastníchrukou.ID = "lblDovlastníchrukou";
                    _lblDovlastníchrukou.Text = "Do vlastních rukou";
                    _chbDoVlastnichRukou = new CheckBox();
                    _chbDoVlastnichRukou.ID = "chbDoVlastnichRukou";
                    _lblZákazdoručenífikcí = new Label();
                    _lblZákazdoručenífikcí.ID = "lblZákazdoručenífikcí";
                    _lblZákazdoručenífikcí.Text = "Zákaz doručení fikcí";
                    _chbZakazDoruceniFikci = new CheckBox();
                    _chbZakazDoruceniFikci.ID = "chbZakazDoruceniFikci";
                    _lblZmocněníčíslo = new Label();
                    _lblZmocněníčíslo.ID = "lblZmocněníčíslo";
                    _lblZmocněníčíslo.Text = "Zmocnění - číslo zákona";
                    _txbCisloZakona = new RadTextBox();
                    _txbCisloZakona.ID = "txbCisloZakona";
                    _txbCisloZakona.Width = Unit.Pixel(500);
                    _txbCisloZakona.Skin = "WebBlue";
                    _txbCisloZakona.TextMode = InputMode.SingleLine;
                    _lblZmocněnírok = new Label();
                    _lblZmocněnírok.ID = "lblZmocněnírok";
                    _lblZmocněnírok.Text = "Zmocnění - rok vydání zákona";
                    _txbRokVydani = new RadTextBox();
                    _txbRokVydani.ID = "txbRokVydani";
                    _txbRokVydani.TextMode = InputMode.SingleLine;
                    _txbRokVydani.Skin = "WebBlue";
                    _txbRokVydani.Width = Unit.Pixel(500);
                    _lblZmocněníParagraf = new Label();
                    _lblZmocněníParagraf.ID = "lblZmocněníParagraf";
                    _lblZmocněníParagraf.Text = "Zmocnění - Paragraf v zákoně";
                    _txbParagrafVZakone = new RadTextBox();
                    _txbParagrafVZakone.ID = "txbParagrafVZakone";
                    _txbParagrafVZakone.Width = Unit.Pixel(500);
                    _txbParagrafVZakone.Skin = "WebBlue";
                    _txbParagrafVZakone.TextMode = InputMode.SingleLine;
                    _lblZmocněníodstavec = new Label();
                    _lblZmocněníodstavec.ID = "lblZmocněníodstavec";
                    _lblZmocněníodstavec.Text = "Zmocnění - odstavec v paragrafu";
                    _txbOdstavecParagrafu = new RadTextBox();
                    _txbOdstavecParagrafu.ID = "txbOdstavecParagrafu";
                    _txbOdstavecParagrafu.Width = Unit.Pixel(500);
                    _txbOdstavecParagrafu.TextMode = InputMode.SingleLine;
                    _txbOdstavecParagrafu.Skin = "WebBlue";
                    _lblZmocněnípísmeno = new Label();
                    _lblZmocněnípísmeno.ID = "lblZmocněnípísmeno";
                    _lblZmocněnípísmeno.Text = "Zmocnění - písmeno v odstavci";
                    _txbPismeniVOdstavci = new RadTextBox();
                    _txbPismeniVOdstavci.ID = "txbPismeniVOdstavci";
                    _txbPismeniVOdstavci.Width = Unit.Pixel(500);
                    _txbPismeniVOdstavci.Skin = "WebBlue";
                    _txbPismeniVOdstavci.TextMode = InputMode.SingleLine;
                    _lblPoznámka = new Label();
                    _lblPoznámka.ID = "lblPoznámka";
                    _lblPoznámka.Text = "Poznámka";
                    _txbPoznamka = new RadTextBox();
                    _txbPoznamka.ID = "txbPoznamka";
                    _txbPoznamka.Width = Unit.Pixel(500);
                    _txbPoznamka.TextMode = InputMode.MultiLine;
                    _txbPoznamka.Skin = "WebBlue";
                    _txbPoznamka.Rows = 3;

                    _lblPřílohy = new Label();
                    _lblPřílohy.ID = "lblPřílohy";
                    _lblPřílohy.Text = "Přílohy(Povolené přípony souborů:PDF, RTF, TXT, DOC, XLS, DOCX, XLSX, JPG, GIF)";
                    _RadUpload1 = new RadUpload();
                    _RadUpload1.ID = "RadUpload1";
                    _RadUpload1.InitialFileInputsCount = 1;
                    _RadUpload1.MaxFileInputsCount = 10;
                    _RadUpload1.MaxFileSize = 10000000; // Few more properties to be defined later
                    _RadUpload1.ControlObjectsVisibility = ControlObjectsVisibility.AddButton;
                    _RadUpload1.Skin = "WebBlue";
                    _RadUpload1.Width = Unit.Pixel(500);
                    //_RadUpload1.TargetFolder = "~/UploadFiles";
                    _RadUpload1.EnableFileInputSkinning = false;

                    _btnSave = new Button();
                    _btnSave.ID = "btnSave";
                    _btnSave.Text = "Uložit k dopracování";
                    _btnSave.Click += new EventHandler(_btnSave_Click);
                    _btnSend = new Button();
                    _btnSend.ID = "btnSend";
                    _btnSend.Text = "Odeslat";
                    _btnSend.Click += new EventHandler(_btnSend_Click);
                    // End Table 5 Controls
                    lblblank = new Label();
                    lblblank.ID = "lblblank";
                    lblblank.Text = string.Empty;
                    string[] allowedFileExtensions = new string[10] { ".pdf", ".doc", ".docx", ".gif", ".jpg", ".jpeg", ".xls", ".xlsx", ".rtf", ".txt" };
                    _RadUpload1.AllowedFileExtensions = allowedFileExtensions;
                
                // Creating Table
                    CreateTable(ref _tblSearch);
                    CreateTable(ref _tblFyzická);
                    CreateTable(ref _tblPodnikající);
                    CreateTable(ref _tblPrávnická);
                    CreateTable(ref _tblOVM);
                    CreateTable(ref _tblUpdate);
                // End Creating Table
                    _panel.Controls.Add(_tblSearch);
                    _panel.Controls.Add(_tblFyzická);
                    _panel.Controls.Add(_tblPodnikající);
                    _panel.Controls.Add(_tblPrávnická);
                    _panel.Controls.Add(_tblOVM);
                    _panel.Controls.Add(_tblUpdate);
             
                    Controls.Add(_panel);



                    WebPartManager wp = WebPartManager.GetCurrentWebPartManager(Page);
                    if (wp.DisplayMode == WebPartManager.DesignDisplayMode || wp.DisplayMode.Name == "Edit")
                    {
                        Controls.Clear();
                        Label label = new Label();
                        label.Text = "Output of controls disabled in design mode";
                        Controls.Add(label);
                    }

                    else
                    {

                        SPContext context = SPContext.Current;
                        SPSite site = context.Site;
                        oWebSite = site.OpenWeb("ds");
                        //am = new RadAjaxManager();
                        //am.ID = "RadAjaxManager1";
                        //Controls.Add(am);
                        //Page.Items.Add(typeof(RadAjaxManager), am);
                        lp = new RadAjaxLoadingPanel();
                        lp.ID = "RadAjaxLoadingPanel1";
                        //  lp.IsSticky = true; Check this property for the position of Loading Panel..
                        Controls.Add(lp);
                        lp.Skin = "Sunset";
                        lp.EnableSkinTransparency = false;
                        lp.Transparency = 50;

                        //img = new System.Web.UI.WebControls.Image();
                        //img.ID = "Image1";
                        //lp.Controls.Add(img);
                        //img.AlternateText = "Loading...";
                        //img.ImageUrl = RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif");
                        //img.Style.Add("border", "0px");

                        am.DefaultLoadingPanelID = lp.ID;

                        

                    }
                    FillSearchCombo();
                    if (!Page.IsPostBack)
                    {

                        _cobSkartacniSymbol.Items.Add(new RadComboBoxItem("A", "A"));
                        _cobSkartacniSymbol.Items.Add(new RadComboBoxItem("S1", "S1"));
                        _cobSkartacniSymbol.Items.Add(new RadComboBoxItem("S2", "S2"));
                        _cobSkartacniSymbol.Items.Add(new RadComboBoxItem("S3", "S3"));
                        _cobSkartacniSymbol.Items.Add(new RadComboBoxItem("S5", "S5"));
                        _cobSkartacniSymbol.Items.Add(new RadComboBoxItem("S10", "S10"));
                        _cobSkartacniSymbol.Items.Add(new RadComboBoxItem("S15", "S15"));
                        _cobSkartacniSymbol.Items.Add(new RadComboBoxItem("S20", "S20"));
                        _cobSkartacniSymbol.Items.Add(new RadComboBoxItem("S45", "S45"));
                        _cobSkartacniSymbol.Items.Add(new RadComboBoxItem("V1", "V1"));
                        _cobSkartacniSymbol.Items.Add(new RadComboBoxItem("V3", "V3"));
                        _cobSkartacniSymbol.Items.Add(new RadComboBoxItem("V5", "V5"));
                        _cobSkartacniSymbol.Items.Add(new RadComboBoxItem("V10", "V10"));

                        SPListItemCollection itemsAdresar = null;
                        SPListItemCollection itemsDatoveSchranky = null;

                        // Nacteni adresare z Cache
                        itemsAdresar = (SPListItemCollection)this.Page.Cache["AdresarItems"];
                        itemsDatoveSchranky = (SPListItemCollection)this.Page.Cache["DatoveSchrankyItems"];
                        try
                        {
                            // Neni v cachi
                            if (itemsAdresar == null)
                            {
                                // Nacteni listu Adresar
                                SPList list = oWebSite.Lists[listAdresar];
                                itemsAdresar = list.Items;
                                this.Page.Cache.Add("AdresarItems",
                                    itemsAdresar,
                                    null,
                                    DateTime.Now.AddMinutes(2),
                                    System.Web.Caching.Cache.NoSlidingExpiration,
                                    System.Web.Caching.CacheItemPriority.High,
                                    null);
                            }
                        }
                        catch (Exception Ex)
                        {
                            _lbl1Errors.Text += "<br/>Nenalezen seznam '<i>" + listAdresar + "</i>'.";
                        }

                        try
                        {
                            // Neni v cachi
                            if (itemsDatoveSchranky == null)
                            {
                                // Nacteni listu Archiv
                                SPList list = oWebSite.Lists[listNastaveni];
                                itemsDatoveSchranky = list.Items;
                                this.Page.Cache.Add("DatoveSchrankyItems",
                                       itemsDatoveSchranky,
                                       null,
                                       DateTime.Now.AddMinutes(2),
                                       System.Web.Caching.Cache.NoSlidingExpiration,
                                       System.Web.Caching.CacheItemPriority.High,
                                       null);
                            }
                        }
                        catch (Exception Ex)
                        {
                            _lbl1Errors.Text += "<br/>Nenalezen seznam '<i>" + listNastaveni + "</i>'.";
                        }

                        try
                        {
                            // Pridani hodnot do comboBoxu s preddefinovanymi prijemci
                            foreach (SPListItem item in itemsAdresar)
                            {
                                if (item != null)
                                {
                                    _cobPredPrijemce.Items.Add(new RadComboBoxItem(item.Title, item[itemIDDS].ToString()));
                                }

                            }
                        }
                        catch (Exception Ex)
                        {
                            _lbl1Errors.Text += "<br/>Nenalezena položka '<i>" + itemIDDS + "</i>' v seznamu '<i>" + listAdresar + "</i>'.";
                        }

                        try
                        {
                            // Pridani hodnot do comboBoxu s datovými schránkami odesilatele
                            foreach (SPListItem item in itemsDatoveSchranky)
                            {
                                if (item != null)
                                {
                                    _cobOdesilatel.Items.Add(new RadComboBoxItem(item.Title, item.ID.ToString()));
                                }

                            }
                        }
                        catch (Exception Ex)
                        {
                            _lbl1Errors.Text += "<br/>Nenalezena položka '<i>ID</i>' v seznamu '<i>" + listNastaveni + "</i>'.";
                        }

                        _radGrid1.Visible = false;
                        _tblOVM.Visible = false;
                        _tblPodnikající.Visible = false;
                        _tblPrávnická.Visible = false;
                        _tblFyzická.Visible = true;
                        _tblUpdate.Visible = false;
                        _tblSearch.Visible = true;
                        _tblDataGrid.Visible = false;
                    }




                }
                catch (Exception ex)
                {
                    Controls.Clear();
                    Label label = new Label();
                    label.Text = ex.ToString();
                    Controls.Add(label);
                }




            }

            # region "Button Click Events"
            protected void _btn1Search_Click(object sender, EventArgs e)
            {


                // Start: New Code Added by Amit
                am.AjaxSettings.AddAjaxSetting(_btn1Search,_panel);
                bool isError = false;
                _lbl1Errors.Text = String.Empty;

                DataTable table = new DataTable();
                table.Columns.Add("IDDS", typeof(string));
                table.Columns.Add("Jméno", typeof(string));
                table.Columns.Add("Přijmení", typeof(string));
                table.Columns.Add("Adresa", typeof(string));
                table.Columns.Add("Datum narození", typeof(string));

                if (_txb1IDSchranky.Text.Length == 0)
                {
                    if (_txb1Jmeno.Text.Length == 0 || _txb1Prijmeni.Text.Length == 0)
                    {
                        _lbl1Errors.Text = "<br/>Nejsou vyplněny povinné položky!";
                        isError = true;
                    }
                }
                else
                {
                    if (_txb1IDSchranky.Text.Length != 7)
                    {
                        if (_txb1Jmeno.Text.Length == 0 && _txb1Prijmeni.Text.Length == 0)
                        {
                            _lbl1Errors.Text = "<br/>Do vyhledávacího pole ID schránky musíte zadat 7 znaků. Doplňte je a stiskněte znovu tlačítko Vyhledat.";
                            isError = true;
                        }
                        else if ((_txb1Jmeno.Text.Length > 0 && _txb1Prijmeni.Text.Length == 0) || (_txb1Jmeno.Text.Length == 0 && _txb1Prijmeni.Text.Length > 0))
                        {
                            _lbl1Errors.Text = "<br/>Do vyhledávacího pole ID schránky musíte zadat 7 znaků. Doplňte je a stiskněte znovu tlačítko Vyhledat.";
                            _lbl1Errors.Text += "<br/>Nejsou vyplněny povinné položky!";
                            isError = true;
                        }
                        else
                        {
                            _lbl1Errors.Text = "<br/>Do vyhledávacího pole ID schránky musíte zadat 7 znaků. Doplňte je a stiskněte znovu tlačítko Vyhledat.";
                            isError = true;
                        }
                    }
                    else
                    {
                        //if ((txb1Jmeno.Text.Length > 0 && txb1Prijmeni.Text.Length == 0) || (txb1Jmeno.Text.Length == 0 && txb1Prijmeni.Text.Length > 0))
                        //{
                        //    lbl1Errors.Text = "<br/>Nejsou vyplněny povinné položky!";
                        //    isError = true;
                        //}
                    }
                }

                if (!String.IsNullOrEmpty(_txb1Jmeno.Text) && !String.IsNullOrEmpty(_txb1Prijmeni.Text))
                {
                    if (_txb1Jmeno.Text.Length < 2)
                    {
                        _lbl1Errors.Text += "<br/>Do vyhledávacího pole Jméno musíte zadat alespoň dva znaky.";
                        isError = true;
                    }
                    if (_txb1Prijmeni.Text.Length < 2)
                    {
                        _lbl1Errors.Text += "<br/>Do vyhledávacího pole Příjmení musíte zadat alespoň dva znaky. ";
                        isError = true;
                    }

                }


                // Jestlize neni chyba ve vstupnich udajich
                if (!isError)
                {
                    try
                    {
                        GetLoginInformation();

                        ISDSBox ownBox;
                        Exception ex = new Exception();


                        ownBox = BoxFce.ConnectToAccount(LoginName1, Password1,
                                              WebServiceUserAgent.ToString(),
                                              BaseUri.ToString(),
                                              Proxydomain.ToString(),
                                              ProxyLogin.ToString(),
                                              ProxyPass.ToString(),
                                              bool.Parse(UseProxy.ToString()),
                                              out ex);

                        if (ownBox == null)
                        {
                            _lbl1Errors.Text += "<br/>Nepodařilo se přihlášit k datové schránce.";
                            //lbl1Errors.Text += "<br/>" + ex.Message + "<br/>" + ex.StackTrace;
                        }
                        else
                        {
                            ISDSOwnerInfo findBox = new ISDSOwnerInfo();

                            findBox.ID = _txb1IDSchranky.Text;
                            findBox.FirstName = _txb1Jmeno.Text;
                            findBox.LastName = _txb1Prijmeni.Text;

                            if (!_txb1DatumNarozeni.Text.Equals("00000000"))
                            {
                                string[] tempDate = _txb1DatumNarozeni.TextWithPromptAndLiterals.Split(new Char[] { '.' });

                                findBox.BirthDate = new DateTime((int)tempDate.GetValue(2), (int)tempDate.GetValue(1), (int)tempDate.GetValue(0));
                            }

                            if (_txb1Obec.Text.Length > 0)
                            {
                                findBox.City = _txb1Obec.Text;
                            }

                            if (_txb1Ulice.Text.Length > 0)
                            {
                                findBox.Street = _txb1Ulice.Text;
                            }

                            if (_txb1CisloOrientacni.Text.Length > 0)
                            {
                                findBox.NumberInStreet = _txb1CisloOrientacni.Text;
                            }

                            if (_txb1CisloPopisne.Text.Length > 0)
                            {
                                findBox.NumberInMunicipality = _txb1CisloPopisne.Text;
                            }

                            findBox.Type = tDbType.FO;

                            int StatusCode;
                            string RefNumber;
                            string StatusMessage;

                            ISDSOwnerInfo[] findItems = ownBox.FindDataBox(findBox, out StatusCode, out StatusMessage, out RefNumber);

                            //lblCountOfResults.Text = "<br/>Počet nalezených schránek: " + findItems.Count().ToString();

                            this.Page.Cache.Remove(oWebSite.CurrentUser.LoginName + "_FindBoxes");
                            this.Page.Cache.Add(oWebSite.CurrentUser.LoginName + "_FindBoxes",
                                 findItems,
                                 null,
                                 DateTime.Now.AddMinutes(2),
                                 System.Web.Caching.Cache.NoSlidingExpiration,
                                 System.Web.Caching.CacheItemPriority.High,
                                 null);


                            table = new DataTable();
                            table.Columns.Add("IDDS", typeof(string));
                            table.Columns.Add("Jméno", typeof(string));
                            table.Columns.Add("Přijmení", typeof(string));
                            table.Columns.Add("Adresa", typeof(string));
                            table.Columns.Add("Datum narození", typeof(string));

                            foreach (ISDSOwnerInfo findItem in findItems)
                            {
                                table.Rows.Add(findItem.ID, findItem.FirstName, findItem.LastName, findItem.Street + " " + findItem.NumberInMunicipality + (findItem.NumberInStreet.Equals("") ? "/" + findItem.NumberInStreet : "") + ", " + findItem.City + " " + findItem.ZipCode, findItem.BirthDate.Value.ToShortDateString());
                            }
                            // Start: Uncomment this code when search function starts
                            //_radGrid1.DataSource = table;
                            //_radGrid1.MasterTableView.DataKeyNames = new String[1] { "IDDS" };
                            //_radGrid1.DataBind();
                            //_tblDataGrid.Visible = true;
                            // End: Uncomment this code when search function starts

                        }
                        //Start: comment this function when search function start: only for testing
                        if (table.Rows.Count == 0)
                        {
                            table.Rows.Add("IDDS Record1", "Jméno Record1", "Přijmení Record1", "Adresa Record1", "Datum narození Record1");
                            table.Rows.Add("IDDS Record2", "Jméno Record2", "Přijmení Record2", "Adresa Record2", "Datum narození Record2");

                            _radGrid1.DataSource = table;
                            //_radGrid1.MasterTableView.DataKeyNames = new String[1] { "IDDS" };
                            _radGrid1.DataBind();
                            AddTableGrid(ref _tblFyzická);

                        }
                        //End: comment this function when search function start: only for testing
                    }
                    catch (Exception Ex)
                    {
                        _lbl1Errors.Text += "<br/>Nepodařilo se připojit k datové schránce!";

                        //lbl1Errors.Text += "Nepodařilo se připojit k datové schránce!<br/><br/>" +  Ex.ToString();
                    }

                }
                // End: New Code Added by Amit
            }

            protected void _btn2Search_Click(object sender, EventArgs e)
            {
                am.AjaxSettings.AddAjaxSetting(_btn2Search, _panel);
                bool isError = false;
                _lbl2Errors.Text = String.Empty;
                DataTable table = new DataTable();
                table.Columns.Add("IDDS", typeof(string));
                table.Columns.Add("Identifikační číslo (IČ)", typeof(string));
                table.Columns.Add("Název organizace", typeof(string));
                table.Columns.Add("Jméno", typeof(string));
                table.Columns.Add("Přijmení", typeof(string));
                table.Columns.Add("Adresa", typeof(string));
                table.Columns.Add("Datum narození", typeof(string));

                if (String.IsNullOrEmpty(_txb2IDSchranky.Text) &&
                    String.IsNullOrEmpty(_txb2IC.Text) &&
                    String.IsNullOrEmpty(_txb2IC.Text) &&
                    String.IsNullOrEmpty(_txb2Jmeno.Text) &&
                    String.IsNullOrEmpty(_txb2Prijmeni.Text))
                {
                    _lbl2Errors.Text = "<br/>Nejsou vyplněny povinné položky!";
                    isError = true;
                }
                else
                {
                    if (!String.IsNullOrEmpty(_txb2IDSchranky.Text))
                    {
                        if (_txb2IDSchranky.Text.Length != 7)
                        {
                            _lbl2Errors.Text = "<br/>Do vyhledávacího pole ID schránky musíte zadat 7 znaků. Doplňte je a stiskněte znovu tlačítko Vyhledat.";
                            isError = true;
                        }
                    }

                    if (((!String.IsNullOrEmpty(_txb2Jmeno.Text) && String.IsNullOrEmpty(_txb2Prijmeni.Text)) ||
                        (String.IsNullOrEmpty(_txb2Jmeno.Text) && !String.IsNullOrEmpty(_txb2Prijmeni.Text))) &&
                        String.IsNullOrEmpty(_txb2IDSchranky.Text) &&
                        String.IsNullOrEmpty(_txb2IC.Text))
                    {
                        _lbl2Errors.Text += "<br/>Nejsou vyplněny povinné položky!";
                        isError = true;
                    }

                    if (!String.IsNullOrEmpty(_txb2Jmeno.Text) && !String.IsNullOrEmpty(_txb2Prijmeni.Text))
                    {
                        if (_txb2Jmeno.Text.Length < 2)
                        {
                            _lbl2Errors.Text += "<br/>Do vyhledávacího pole Jméno musíte zadat alespoň dva znaky.";
                            isError = true;
                        }
                        if (_txb2Prijmeni.Text.Length < 2)
                        {
                            _lbl2Errors.Text += "<br/>Do vyhledávacího pole Příjmení musíte zadat alespoň dva znaky. ";
                            isError = true;
                        }

                    }


                }

                // Jestlize neni chyba ve vstupnich udajich
                if (!isError)
                {
                    try
                    {
                        GetLoginInformation();

                        ISDSBox ownBox;
                        Exception ex = new Exception();

                        //ownBox = BoxFce.ConnectToAccount(LoginName1, Password1,
                        //    ConfigurationSettings.AppSettings["WebServiceUserAgent"],
                        //    ConfigurationSettings.AppSettings["BaseUri"],
                        //    ConfigurationSettings.AppSettings["Proxydomain"],
                        //    ConfigurationSettings.AppSettings["ProxyLogin"],
                        //    ConfigurationSettings.AppSettings["ProxyPass"],
                        //    bool.Parse(ConfigurationSettings.AppSettings["UseProxy"]),
                        //    out ex);

                        ownBox = BoxFce.ConnectToAccount(LoginName1, Password1,
                                           WebServiceUserAgent.ToString(),
                                           BaseUri.ToString(),
                                           Proxydomain.ToString(),
                                           ProxyLogin.ToString(),
                                           ProxyPass.ToString(),
                                           bool.Parse(UseProxy.ToString()),
                                           out ex);

                        if (ownBox == null)
                        {
                            _lbl2Errors.Text += "<br/>Nepodařilo se přihlásit k datové schránce.";
                            //lbl2Errors.Text += "<br/>" + ex.Message + "<br/>" + ex.StackTrace;
                        }
                        else
                        {
                            ISDSOwnerInfo findBox = new ISDSOwnerInfo();

                            findBox.ID = _txb2IDSchranky.Text.Trim();
                            findBox.FirstName = _txb2Jmeno.Text.Trim();
                            findBox.LastName = _txb2Prijmeni.Text.Trim();
                            findBox.IC = _txb2IC.Text.Trim();

                            if (_txb2ObecMistaPodnikani.Text.Length > 0)
                            {
                                findBox.City = _txb2ObecMistaPodnikani.Text;
                            }

                            if (_txb2UliceMistaPodnikani.Text.Length > 0)
                            {
                                findBox.Street = _txb2UliceMistaPodnikani.Text;
                            }

                            if (_txb2CisloOrientacni.Text.Length > 0)
                            {
                                findBox.NumberInStreet = _txb2CisloOrientacni.Text;
                            }

                            if (_txb2CisloPopisne.Text.Length > 0)
                            {
                                findBox.NumberInMunicipality = _txb2CisloPopisne.Text;
                            }

                            findBox.Type = tDbType.PFO;

                            int StatusCode;
                            string RefNumber;
                            string StatusMessage;

                            ISDSOwnerInfo[] findItems = ownBox.FindDataBox(findBox, out StatusCode, out StatusMessage, out RefNumber);

                            //_lblCountOfResults.Text = "Počet nalezených schránek: " + findItems.Count().ToString();

                            this.Page.Cache.Remove(oWebSite.CurrentUser.LoginName + "_FindBoxes");
                            this.Page.Cache.Add(oWebSite.CurrentUser.LoginName + "_FindBoxes",
                                findItems,
                                null,
                                DateTime.Now.AddMinutes(2),
                                System.Web.Caching.Cache.NoSlidingExpiration,
                                System.Web.Caching.CacheItemPriority.High,
                                null);

                            // table = new DataTable();
                            //table.Columns.Add("IDDS", typeof(string));
                            //table.Columns.Add("Identifikační číslo (IČ)", typeof(string));
                            //table.Columns.Add("Název organizace", typeof(string));
                            //table.Columns.Add("Jméno", typeof(string));
                            //table.Columns.Add("Přijmení", typeof(string));
                            //table.Columns.Add("Adresa", typeof(string));
                            //table.Columns.Add("Datum narození", typeof(string));

                            foreach (ISDSOwnerInfo findItem in findItems)
                            {
                                table.Rows.Add(findItem.ID, findItem.IC, findItem.FirmName, findItem.FirstName, findItem.LastName, findItem.Street + " " + findItem.NumberInMunicipality + (findItem.NumberInStreet.Equals("") ? "/" + findItem.NumberInStreet : "") + ", " + findItem.City + " " + findItem.ZipCode, findItem.BirthDate.Value.ToShortDateString());
                            }

                            //_radGrid1.DataSource = table;
                            //_radGrid1.MasterTableView.DataKeyNames = new String[1] { "IDDS" };
                            //_radGrid1.DataBind();
                            //_tblDataGrid.Visible = true;

                        }
                        // Added by Amit for testing
                        if (table.Rows.Count == 0)
                        {
                            table.Rows.Add("IDDS Record1", "Identifikační číslo (IČ)", "Název organizace Record1", "Jméno Record1", "Přijmení Record1", "Adresa Record1", "Datum narození Record1");
                            table.Rows.Add("IDDS Record2", "Identifikační číslo (IČ)", "Název organizace Record1", "Jméno Record2", "Přijmení Record2", "Adresa Record2", "Datum narození Record2");
                            _radGrid1.DataSource = table;
                            _radGrid1.DataBind();
                            AddTableGrid(ref _tblPodnikající);
                        }
                        // Done by Amit for testing
                    }
                    catch (Exception Ex)
                    {
                        _lbl2Errors.Text = "<br/>Nepodařilo se připojit k datové schránkce!";
                    }

                }



            }

            protected void _btn3Search_Click(object sender, EventArgs e)
            {
                bool isError = false;
                _lbl3Errors.Text = String.Empty;


                if (String.IsNullOrEmpty(_txb3IDSchranky.Text) &&
                    String.IsNullOrEmpty(_txb3IC.Text) &&
                    String.IsNullOrEmpty(_txb3NazevOrganizace.Text))
                {
                    _lbl3Errors.Text += "<br/>Nejsou vyplněny povinné položky!";
                    isError = true;
                }
                else
                {
                    if (!String.IsNullOrEmpty(_txb3IDSchranky.Text))
                    {
                        if (_txb3IDSchranky.Text.Length != 7)
                        {
                            _lbl3Errors.Text += "<br/>Do vyhledávacího pole ID schránky musíte zadat 7 znaků. Doplňte je a stiskněte znovu tlačítko Vyhledat.";
                            isError = true;
                        }

                    }
                    if (!String.IsNullOrEmpty(_txb3NazevOrganizace.Text))
                    {
                        if (_txb3NazevOrganizace.Text.Length < 2)
                        {
                            _lbl3Errors.Text += "<br/>Do vyhledávacího pole Název organizace musíte zadat alespoň dva znaky. Doplňte je a stiskněte znovu tlačítko Vyhledat.";
                            isError = true;
                        }
                    }
                }


                if (!isError)
                {
                    try
                    {
                        GetLoginInformation();

                        ISDSBox ownBox;
                        Exception ex = new Exception();

                        //ownBox = BoxFce.ConnectToAccount(LoginName1, Password1,
                        //ConfigurationSettings.AppSettings["WebServiceUserAgent"],
                        //ConfigurationSettings.AppSettings["BaseUri"],
                        //ConfigurationSettings.AppSettings["Proxydomain"],
                        //ConfigurationSettings.AppSettings["ProxyLogin"],
                        //ConfigurationSettings.AppSettings["ProxyPass"],
                        //bool.Parse(ConfigurationSettings.AppSettings["UseProxy"]),
                        //out ex);

                        ownBox = BoxFce.ConnectToAccount(LoginName1, Password1,
                           WebServiceUserAgent.ToString(),
                           BaseUri.ToString(),
                           Proxydomain.ToString(),
                           ProxyLogin.ToString(),
                           ProxyPass.ToString(),
                           bool.Parse(UseProxy.ToString()),
                           out ex);

                        if (ownBox == null)
                        {
                            _lbl3Errors.Text += "<br/>Nepodařilo se přihlásit k datové schránce.";
                            //lbl3Errors.Text += "<br/>" + ex.Message + "<br/>" + ex.StackTrace;
                        }
                        else
                        {
                            ISDSOwnerInfo findBox = new ISDSOwnerInfo();

                            findBox.ID = _txb3IDSchranky.Text.Trim();
                            findBox.FirmName = _txb3NazevOrganizace.Text.Trim();
                            findBox.IC = _txb3IC.Text.Trim();

                            findBox.Type = tDbType.PO;

                            int StatusCode;
                            string RefNumber;
                            string StatusMessage;

                            ISDSOwnerInfo[] findItems = ownBox.FindDataBox(findBox, out StatusCode, out StatusMessage, out RefNumber);

                            //lblCountOfResults.Text = "Počet nalezených schránek: " + findItems.Count().ToString();

                            this.Page.Cache.Remove(oWebSite.CurrentUser.LoginName + "_FindBoxes");
                            this.Page.Cache.Add(oWebSite.CurrentUser.LoginName + "_FindBoxes",
                                findItems,
                                null,
                                DateTime.Now.AddMinutes(2),
                                System.Web.Caching.Cache.NoSlidingExpiration,
                                System.Web.Caching.CacheItemPriority.High,
                                null);

                            DataTable table = new DataTable();
                            table.Columns.Add("IDDS", typeof(string));
                            table.Columns.Add("Identifikační číslo (IČ)", typeof(string));
                            table.Columns.Add("Název organizace", typeof(string));
                            table.Columns.Add("Adresa", typeof(string));

                            foreach (ISDSOwnerInfo findItem in findItems)
                            {
                                table.Rows.Add(findItem.ID, findItem.IC, findItem.FirmName, findItem.Street + " " + findItem.NumberInMunicipality + (findItem.NumberInStreet.Equals("") ? "/" + findItem.NumberInStreet : "") + ", " + findItem.City + " " + findItem.ZipCode);
                            }

                            _radGrid1.DataSource = table;
                            _radGrid1.MasterTableView.DataKeyNames = new String[1] { "IDDS" };
                            _radGrid1.DataBind();

                        }
                    }
                    catch (Exception Ex)
                    {
                        _lbl3Errors.Text = "<br/>Nepodařilo se připojit k datové schránkce!";
                    }


                }

            }

            protected void _btn4Search_Click(object sender, EventArgs e)
            {

                bool isError = false;
                _lbl4Errors.Text = String.Empty;


                if (String.IsNullOrEmpty(_txb4IDSchranky.Text) &&
                    String.IsNullOrEmpty(_txb4IC.Text) &&
                    String.IsNullOrEmpty(_txb4Nazevorganizace.Text))
                {
                    _lbl4Errors.Text += "<br/>Nejsou vyplněny povinné položky!";
                    isError = true;
                }
                else
                {
                    if (!String.IsNullOrEmpty(_txb4IDSchranky.Text))
                    {
                        if (_txb4IDSchranky.Text.Length != 7)
                        {
                            _lbl4Errors.Text += "<br/>Do vyhledávacího pole ID schránky musíte zadat 7 znaků. Doplňte je a stiskněte znovu tlačítko Vyhledat.";
                            isError = true;
                        }

                    }
                    if (!String.IsNullOrEmpty(_txb4Nazevorganizace.Text))
                    {
                        if (_txb4Nazevorganizace.Text.Length < 2)
                        {
                            _lbl4Errors.Text += "<br/>Do vyhledávacího pole Název organizace musíte zadat alespoň dva znaky. Doplňte je a stiskněte znovu tlačítko Vyhledat.";
                            isError = true;
                        }
                    }
                }


                if (!isError)
                {

                    try
                    {
                        GetLoginInformation();

                        ISDSBox ownBox;
                        Exception ex = new Exception();

                        //ownBox = BoxFce.ConnectToAccount(LoginName1, Password1,
                        //    ConfigurationSettings.AppSettings["WebServiceUserAgent"],
                        //    ConfigurationSettings.AppSettings["BaseUri"],
                        //    ConfigurationSettings.AppSettings["Proxydomain"],
                        //    ConfigurationSettings.AppSettings["ProxyLogin"],
                        //    ConfigurationSettings.AppSettings["ProxyPass"],
                        //    bool.Parse(ConfigurationSettings.AppSettings["UseProxy"]),
                        //    out ex);


                        ownBox = BoxFce.ConnectToAccount(LoginName1, Password1,
                                              WebServiceUserAgent.ToString(),
                                              BaseUri.ToString(),
                                              Proxydomain.ToString(),
                                              ProxyLogin.ToString(),
                                              ProxyPass.ToString(),
                                              bool.Parse(UseProxy.ToString()),
                                              out ex);


                        if (ownBox == null)
                        {
                            _lbl4Errors.Text += "<br/>Nepodařilo se přihlásit k datové schránce.";
                            //lbl4Errors.Text += "<br/>" + ex.Message + "<br/>" + ex.StackTrace;
                            //lbl4Errors.Text += "<br/>" + ex.Message + "<br/>" + ex.StackTrace;
                        }
                        else
                        {
                            ISDSOwnerInfo findBox = new ISDSOwnerInfo();

                            findBox.ID = _txb4IDSchranky.Text.Trim();
                            findBox.FirmName = _txb4Nazevorganizace.Text.Trim();
                            findBox.IC = _txb4IC.Text.Trim();

                            findBox.Type = tDbType.OVM;

                            int StatusCode;
                            string RefNumber;
                            string StatusMessage;

                            ISDSOwnerInfo[] findItems = ownBox.FindDataBox(findBox, out StatusCode, out StatusMessage, out RefNumber);

                            this.Page.Cache.Remove(oWebSite.CurrentUser.LoginName + "_FindBoxes");
                            this.Page.Cache.Add(oWebSite.CurrentUser.LoginName + "_FindBoxes",
                                   findItems,
                                   null,
                                   DateTime.Now.AddMinutes(2),
                                   System.Web.Caching.Cache.NoSlidingExpiration,
                                   System.Web.Caching.CacheItemPriority.High,
                                   null);

                            //lblCountOfResults.Text = "Počet nalezených schránek: " + findItems.Count().ToString();

                            DataTable table = new DataTable();
                            table.Columns.Add("IDDS", typeof(string));
                            table.Columns.Add("Identifikační číslo (IČ)", typeof(string));
                            table.Columns.Add("Název organizace", typeof(string));
                            table.Columns.Add("Adresa", typeof(string));

                            foreach (ISDSOwnerInfo findItem in findItems)
                            {
                                table.Rows.Add(findItem.ID, findItem.IC, findItem.FirmName, findItem.Street + " " + findItem.NumberInMunicipality + (findItem.NumberInStreet.Equals("") ? "/" + findItem.NumberInStreet : "") + ", " + findItem.City + " " + findItem.ZipCode);
                            }

                            _radGrid1.DataSource = table;
                            _radGrid1.MasterTableView.DataKeyNames = new String[1] { "IDDS" };
                            _radGrid1.DataBind();
                        }

                    }
                    catch (Exception Ex)
                    {
                        _lbl4Errors.Text += "<br/>Nepodařilo se připojit k datové schránkce!";
                    }




                }

            }

            protected void _btnSend_Click(object sender, EventArgs e)
            {
                bool isError = false;
                _lblSaveError.Text = String.Empty;

                if (_txbVec.Text.Length == 0)
                {
                    _lblSaveError.Text += "<br/>Políčko 'Věc' je povinné!";
                    isError = true;
                }
                if (_txbNazev.Text.Length == 0)
                {
                    _lblSaveError.Text += "<br/>Políčko 'Název' je povinné!";
                    isError = true;
                }

                if (_chbPredPrijemce.Checked == false)
                    if (_chbPredPrijemce.Checked == false)
                    {
                        if (_radGrid1.SelectedValue == null)
                        {
                            _lblSaveError.Text += "<br/>Musíte vybrat adresáta!";
                            isError = true;
                        }
                    }

                if (_chbPredPrijemce.Checked == true)
                {
                    if (_cobPredPrijemce.SelectedValue.Length < 1)
                    {
                        _lblSaveError.Text += "<br/>Musíte vybrat adresáta!";
                        isError = true;
                    }
                }


                if (_RadUpload1.UploadedFiles.Count < 1)
                {
                    _lblSaveError.Text += "<br/>Datová zpráva musí obsahovat alespoň jednu přílohu.";
                    isError = true;
                }

                int filesSize = 0;
                int iErrorCount = 0;
                IDictionary<String, String> iFiles = new Dictionary<String, String>();
                foreach (UploadedFile file in _RadUpload1.UploadedFiles)
                {
                    filesSize += file.ContentLength;

                    if (iFiles.ContainsKey(file.GetName()))
                    {
                        if (iErrorCount == 0)
                        {
                            _lblSaveError.Text += "<br/>Zadali jste soubory se stejným jménem.";
                            iErrorCount++;
                        }
                        isError = true;
                    }
                    else
                    {
                        iFiles.Add(file.GetName(), file.GetName());
                    }
                }

                if (filesSize > 10000000)
                {
                    _lblSaveError.Text += "<br/>Maximální velikost všech souborů musí být menší než 10 MB.";
                    isError = true;
                }

                if (!isError)
                {
                    String sPrijemce = String.Empty;
                    String sPrijemceID = String.Empty;
                    String sTypDS = String.Empty;

                    try
                    {

                        if (_chbPredPrijemce.Checked == false)
                        {
                            // nacteni z cache
                            ISDSOwnerInfo[] findItems = (ISDSOwnerInfo[])this.Page.Cache[oWebSite.CurrentUser.LoginName + "_FindBoxes"];
                            ISDSOwnerInfo findItem = null;

                            // jestlize je v cache
                            if (findItems != null)
                            {
                                foreach (ISDSOwnerInfo tempItem in findItems)
                                {
                                    if (tempItem.ID == _radGrid1.SelectedValue.ToString())
                                    {
                                        findItem = tempItem;
                                    }
                                }
                            }

                            // jestlize neni v cache nebo v cachy bylo neco jineho
                            if (findItems == null || findItem == null)
                            {
                                ISDSBox ownBox;
                                Exception ex = new Exception();

                        
                                ownBox = BoxFce.ConnectToAccount(LoginName1, Password1,
                                                      WebServiceUserAgent.ToString(),
                                                      BaseUri.ToString(),
                                                      Proxydomain.ToString(),
                                                      ProxyLogin.ToString(),
                                                      ProxyPass.ToString(),
                                                      bool.Parse(UseProxy.ToString()),
                                                      out ex);

                                if (ownBox != null)
                                {
                                    ownBox.Connect();
                                }

                                ISDSOwnerInfo findBox = new ISDSOwnerInfo();

                                findBox.ID = _radGrid1.SelectedValue.ToString();

                                int StatusCode;
                                string RefNumber;
                                string StatusMessage;

                                findItems = ownBox.FindDataBox(findBox, out StatusCode, out StatusMessage, out RefNumber);
                                findItem = (ISDSOwnerInfo)findItems.GetValue(0);
                            }



                            if (findItem.Type == tDbType.FO)
                            {
                                sPrijemce = findItem.FirstName + " ";
                                sPrijemce += findItem.LastName + ", ";
                                sPrijemce += findItem.Street + " ";
                                sPrijemce += findItem.NumberInMunicipality;
                                sPrijemce += (!string.IsNullOrEmpty(findItem.NumberInStreet) ? "/" + findItem.NumberInStreet : "");
                                sPrijemce += ", " + findItem.City + " " + findItem.ZipCode;
                                sTypDS = "Fyzická osoba";
                            }
                            else if (findItem.Type == tDbType.PFO)
                            {
                                sPrijemce = "IČ " + findItem.IC + ", ";
                                sPrijemce += findItem.FirmName + ", ";
                                sPrijemce += findItem.FirstName + " ";
                                sPrijemce += findItem.LastName + ", ";
                                sPrijemce += findItem.Street + " ";
                                sPrijemce += findItem.NumberInMunicipality;
                                sPrijemce += (!string.IsNullOrEmpty(findItem.NumberInStreet) ? "/" + findItem.NumberInStreet : "");
                                sPrijemce += ", " + findItem.City + " " + findItem.ZipCode;
                                sTypDS = "Podnikající fyzická osoba";
                            }
                            else if (findItem.Type == tDbType.PO)
                            {
                                sPrijemce = "IČ " + findItem.IC + ", ";
                                sPrijemce += findItem.FirmName + ", ";
                                sPrijemce += findItem.Street + " ";
                                sPrijemce += findItem.NumberInMunicipality;
                                sPrijemce += (!string.IsNullOrEmpty(findItem.NumberInStreet) ? "/" + findItem.NumberInStreet : "");
                                sPrijemce += ", " + findItem.City + " " + findItem.ZipCode;
                                sTypDS = "Právnická osoba";
                            }
                            else if (findItem.Type == tDbType.OVM)
                            {
                                sPrijemce = "IČ " + findItem.IC + ", ";
                                sPrijemce += findItem.FirmName + ", ";
                                sPrijemce += findItem.Street + " ";
                                sPrijemce += findItem.NumberInMunicipality;
                                sPrijemce += (!string.IsNullOrEmpty(findItem.NumberInStreet) ? "/" + findItem.NumberInStreet : "");
                                sPrijemce += ", " + findItem.City + " " + findItem.ZipCode;
                                sTypDS = "OVM";
                            }
                            sPrijemceID = findItem.ID;
                        }
                        else
                        {
                            sPrijemce = _cobPredPrijemce.SelectedItem.Text;
                            sPrijemceID = _cobPredPrijemce.SelectedItem.Value;
                        }

                        SPSecurity.RunWithElevatedPrivileges(() =>
                        {

                            bool saveError = false;
                            try
                            {
                                oWebSite.AllowUnsafeUpdates = true;
                                SPList list = oWebSite.Lists["Rozpracované"];

                                SPListItem newItem = list.Items.Add();
                                newItem["Title"] = _txbNazev.Text.Trim();
                                newItem.Update();

                                newItem = list.GetItemById(newItem.ID);
                                newItem["Subject"] = _txbVec.Text.Trim();
                                newItem["IDRecipient"] = sPrijemceID;
                                newItem["Recipient"] = sPrijemce;
                                newItem["TypeDS"] = sTypDS;
                                newItem["LegalTitleSect"] = _txbParagrafVZakone.Text.Trim();
                                newItem["LegalTitleLaw"] = _txbCisloZakona.Text.Trim();
                                newItem["LegalTitleYear"] = _txbRokVydani.Text.Trim();
                                newItem["LegalTitlePar"] = _txbOdstavecParagrafu.Text.Trim();
                                newItem["LegalTitlePoint"] = _txbPismeniVOdstavci.Text.Trim();
                                newItem["SenderRefNumber"] = _txbNasecj.Text.Trim();
                                newItem["SenderIdent"] = _txbNaseSpZn.Text.Trim();
                                newItem["RecipientRefNumber"] = _txbVasecj.Text.Trim();
                                newItem["RecipientIdent"] = _txbVaseSpZn.Text.Trim();
                                newItem["ToHands"] = _txbKRukam.Text.Trim();
                                newItem["Hands"] = _chbDoVlastnichRukou.Checked;
                                newItem["DeliveryFiction"] = _chbZakazDoruceniFikci.Checked;
                                newItem["Annotation"] = _txbPoznamka.Text.Trim();
                                newItem["StatusMessage"] = "K odeslání";
                                newItem["DestructionSymbol"] = _cobSkartacniSymbol.SelectedValue.ToString();

                                newItem["Sender"] = int.Parse(_cobOdesilatel.SelectedItem.Value);
                                newItem["IDDS"] = oWebSite.Lists[listNastaveni.ToString()].Items.GetItemById(int.Parse(_cobOdesilatel.SelectedItem.Value))["IDDS"].ToString();


                                foreach (UploadedFile file in _RadUpload1.UploadedFiles)
                                {
                                    byte[] input = new byte[file.ContentLength];
                                    file.InputStream.Read(input, 0, file.ContentLength);
                                    newItem.Attachments.Add(file.GetName(), input);
                                }

                                newItem.Update();

                            }
                            catch (Exception Ex)
                            {
                                saveError = true;
                                _lblSaveError.Text = Ex.ToString();
                            }

                            if (!saveError)
                            {
                                _lblSaveSuccess.Text = "Datová zpráva byla uložena a čeká na odeslání.";
                            }
                            else
                            {
                                //lblSaveError.Text = "Nastala chyba při ukládání, zkuste akci opakovat!";
                            }



                        });


                    }
                    catch (Exception Ex)
                    {
                        _lblSaveError.Text = Ex.ToString();
                    }
                }

            }

            protected void _btnSave_Click(object sender, EventArgs e)
            {
                bool isError = false;
                _lblSaveError.Text = String.Empty;

                if (_txbVec.Text.Length == 0)
                {
                    _lblSaveError.Text += "<br/>Políčko 'Věc' je povinné!";
                    isError = true;
                }
                if (_txbNazev.Text.Length == 0)
                {
                    _lblSaveError.Text += "<br/>Políčko 'Název' je povinné!";
                    isError = true;
                }

                if (_chbPredPrijemce.Checked == false)
                {
                    if (_radGrid1.SelectedValue == null)
                    {
                        _lblSaveError.Text += "<br/>Musíte vybrat adresáta!";
                        isError = true;
                    }
                }

                if (_chbPredPrijemce.Checked == true)
                {
                    if (_cobPredPrijemce.SelectedValue.Length < 1)
                    {
                        _lblSaveError.Text += "<br/>Musíte vybrat adresáta!";
                        isError = true;
                    }
                }

                int filesSize = 0;
                int iErrorCount = 0;
                IDictionary<String, String> iFiles = new Dictionary<String, String>();
                foreach (UploadedFile file in _RadUpload1.UploadedFiles)
                {
                    filesSize += file.ContentLength;

                    if (iFiles.ContainsKey(file.GetName()))
                    {
                        if (iErrorCount == 0)
                        {
                            _lblSaveError.Text += "<br/>Zadali jste soubory se stejným jménem.";
                            iErrorCount++;
                        }
                        isError = true;
                    }
                    else
                    {
                        iFiles.Add(file.GetName(), file.GetName());
                    }



                }

                if (filesSize > 10000000)
                {
                    _lblSaveError.Text += "<br/>Maximální velikost všech souborů musí být menší než 10 MB.";
                    isError = true;
                }

                if (_RadUpload1.InvalidFiles.Count > 0)
                {
                    _lblSaveError.Text += "<br/>V příloze mohou být pouze soubory s povolenými příponami.";
                    isError = true;
                }



                if (!isError)
                {
                    String sPrijemce = String.Empty;
                    String sPrijemceID = String.Empty;
                    String sTypDS = String.Empty;

                    try
                    {
                        if (_chbPredPrijemce.Checked == false)
                        {

                            ISDSOwnerInfo[] findItems = (ISDSOwnerInfo[])this.Page.Cache[oWebSite.CurrentUser.LoginName + "_FindBoxes"];
                            ISDSOwnerInfo findItem = null;

                            if (findItems != null)
                            {
                                foreach (ISDSOwnerInfo tempItem in findItems)
                                {
                                    if (tempItem.ID == _radGrid1.SelectedValue.ToString())
                                    {
                                        findItem = tempItem;
                                    }
                                }
                            }

                            if (findItems == null || findItem == null)
                            {
                                ISDSBox ownBox;
                                Exception ex = new Exception();

                                //ownBox = BoxFce.ConnectToAccount(LoginName1, Password1,
                                //   ConfigurationSettings.AppSettings["WebServiceUserAgent"],
                                //   ConfigurationSettings.AppSettings["BaseUri"],
                                //   ConfigurationSettings.AppSettings["Proxydomain"],
                                //   ConfigurationSettings.AppSettings["ProxyLogin"],
                                //   ConfigurationSettings.AppSettings["ProxyPass"],
                                //   bool.Parse(ConfigurationSettings.AppSettings["UseProxy"]),
                                //   out ex);

                                ownBox = BoxFce.ConnectToAccount(LoginName1, Password1,
                                                      WebServiceUserAgent.ToString(),
                                                      BaseUri.ToString(),
                                                      Proxydomain.ToString(),
                                                      ProxyLogin.ToString(),
                                                      ProxyPass.ToString(),
                                                      bool.Parse(UseProxy.ToString()),
                                                      out ex);

                                if (ownBox != null)
                                {
                                    ownBox.Connect();
                                }

                                ISDSOwnerInfo findBox = new ISDSOwnerInfo();

                                findBox.ID = _radGrid1.SelectedValue.ToString();

                                int StatusCode;
                                string RefNumber;
                                string StatusMessage;

                                findItems = ownBox.FindDataBox(findBox, out StatusCode, out StatusMessage, out RefNumber);
                                findItem = (ISDSOwnerInfo)findItems.GetValue(0);
                            }


                            if (findItem.Type == tDbType.FO)
                            {
                                sPrijemce = findItem.FirstName + " ";
                                sPrijemce += findItem.LastName + ", ";
                                sPrijemce += findItem.Street + " ";
                                sPrijemce += findItem.NumberInMunicipality;
                                sPrijemce += (!string.IsNullOrEmpty(findItem.NumberInStreet) ? "/" + findItem.NumberInStreet : "");
                                sPrijemce += ", " + findItem.City + " " + findItem.ZipCode;
                                sTypDS = "Fyzická osoba";
                            }
                            else if (findItem.Type == tDbType.PFO)
                            {
                                sPrijemce = "IČ " + findItem.IC + ", ";
                                sPrijemce += findItem.FirmName + ", ";
                                sPrijemce += findItem.FirstName + " ";
                                sPrijemce += findItem.LastName + ", ";
                                sPrijemce += findItem.Street + " ";
                                sPrijemce += findItem.NumberInMunicipality;
                                sPrijemce += (!string.IsNullOrEmpty(findItem.NumberInStreet) ? "/" + findItem.NumberInStreet : "");
                                sPrijemce += ", " + findItem.City + " " + findItem.ZipCode;
                                sTypDS = "Podnikající fyzická osoba";
                            }
                            else if (findItem.Type == tDbType.PO)
                            {
                                sPrijemce = "IČ " + findItem.IC + ", ";
                                sPrijemce += findItem.FirmName + ", ";
                                sPrijemce += findItem.Street + " ";
                                sPrijemce += findItem.NumberInMunicipality;
                                sPrijemce += (!string.IsNullOrEmpty(findItem.NumberInStreet) ? "/" + findItem.NumberInStreet : "");
                                sPrijemce += ", " + findItem.City + " " + findItem.ZipCode;
                                sTypDS = "Právnická osoba";
                            }
                            else if (findItem.Type == tDbType.OVM)
                            {
                                sPrijemce = "IČ " + findItem.IC + ", ";
                                sPrijemce += findItem.FirmName + ", ";
                                sPrijemce += findItem.Street + " ";
                                sPrijemce += findItem.NumberInMunicipality;
                                sPrijemce += (!string.IsNullOrEmpty(findItem.NumberInStreet) ? "/" + findItem.NumberInStreet : "");
                                sPrijemce += ", " + findItem.City + " " + findItem.ZipCode;
                                sTypDS = "OVM";
                            }
                            sPrijemceID = findItem.ID;
                        }
                        else
                        {
                            sPrijemce = _cobPredPrijemce.SelectedItem.Text;
                            sPrijemceID = _cobPredPrijemce.SelectedItem.Value;
                        }

                        SPSecurity.RunWithElevatedPrivileges(() =>
                        {

                            bool saveError = false;
                            try
                            {
                                oWebSite.AllowUnsafeUpdates = true;
                                SPList list = oWebSite.Lists["Rozpracované"];

                                SPListItem newItem = list.Items.Add();
                                newItem["Title"] = _txbNazev.Text.Trim();
                                newItem.SystemUpdate();

                                newItem = list.GetItemById(newItem.ID);
                                newItem["Subject"] = _txbVec.Text.Trim();
                                newItem["IDRecipient"] = sPrijemceID;
                                newItem["Recipient"] = sPrijemce;
                                newItem["TypeDS"] = sTypDS;
                                newItem["LegalTitleSect"] = _txbParagrafVZakone.Text.Trim();
                                newItem["LegalTitleLaw"] = _txbCisloZakona.Text.Trim();
                                newItem["LegalTitleYear"] = _txbRokVydani.Text.Trim();
                                newItem["LegalTitlePar"] = _txbOdstavecParagrafu.Text.Trim();
                                newItem["LegalTitlePoint"] = _txbPismeniVOdstavci.Text.Trim();
                                newItem["SenderRefNumber"] = _txbNasecj.Text.Trim();
                                newItem["SenderIdent"] = _txbNaseSpZn.Text.Trim();
                                newItem["RecipientRefNumber"] = _txbVasecj.Text.Trim();
                                newItem["RecipientIdent"] = _txbVaseSpZn.Text.Trim();
                                newItem["ToHands"] = _txbKRukam.Text.Trim();
                                newItem["Hands"] = _chbDoVlastnichRukou.Checked;
                                newItem["DeliveryFiction"] = _chbZakazDoruceniFikci.Checked;
                                newItem["Annotation"] = _txbPoznamka.Text.Trim();
                                newItem["StatusMessage"] = "K dopracování";
                                newItem["Sender"] = int.Parse(_cobOdesilatel.SelectedItem.Value);
                                newItem["IDDS"] = oWebSite.Lists[listNastaveni.ToString()].Items.GetItemById(int.Parse(_cobOdesilatel.SelectedItem.Value))["IDDS"].ToString();
                                newItem["DestructionSymbol"] = _cobSkartacniSymbol.SelectedValue.ToString();

                                foreach (UploadedFile file in _RadUpload1.UploadedFiles)
                                {
                                    byte[] input = new byte[file.ContentLength];
                                    file.InputStream.Read(input, 0, file.ContentLength);
                                    newItem.Attachments.Add(file.GetName(), input);
                                }

                                newItem.SystemUpdate();
                            }
                            catch (Exception Ex)
                            {
                                saveError = true;
                                //lblSaveError.Text += "<br/>Číslo řádku: "+Ex.ToString()+"<br/>" + Ex.ToString() + "<br/>" +  Ex.Message.ToString() + "<br/>" + Ex.StackTrace.ToString()  ;

                            }

                            if (!saveError)
                            {
                                _lblSaveSuccess.Text += "Datová zpráva byla uložena do seznamu Rozpracované.";
                            }
                            else
                            {
                                _lblSaveError.Text += "Nastala chyba při ukládání, zkuste akci opakovat!";
                            }
                        });
                    }
                    catch (Exception Ex)
                    {
                        _lblSaveError.Text = Ex.ToString();
                    }
                }

            }
            #endregion

            # region "ComboBox Function"

            protected void _cobPredPrijemce_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
            {
                // throw new NotImplementedException();
                am.AjaxSettings.AddAjaxSetting(_cobPredPrijemce, _panel);
               // System.Threading.Thread.Sleep(1000);
                _tblUpdate.Visible = true;
                _tblFyzická.Visible = false;
                _tblPodnikající.Visible = false;
                _tblOVM.Visible = false;
                _tblPrávnická.Visible = false;
                _tblSearch.Visible = true;

            }

            protected void _cobSearchCriteria_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
            {
                
                am.AjaxSettings.AddAjaxSetting(_cobSearchCriteria, _panel);

                if (_cobSearchCriteria.SelectedValue.ToString().Equals("0"))
                {
                    _tblFyzická.Visible = true;
                    _tblPodnikající.Visible = false;
                    _tblPrávnická.Visible = false;
                    _tblOVM.Visible = false;
                    _tblUpdate.Visible = false;
                }
                else if (_cobSearchCriteria.SelectedValue.ToString().Equals("1"))
                {
                    _tblFyzická.Visible = false;
                    _tblPodnikající.Visible = true;
                    _tblPrávnická.Visible = false;
                    _tblOVM.Visible = false;
                    _tblUpdate.Visible = false;
                }

                else if (_cobSearchCriteria.SelectedValue.ToString().Equals("2"))
                {
                    _tblFyzická.Visible = false;
                    _tblPodnikající.Visible = false;
                    _tblPrávnická.Visible = true;
                    _tblOVM.Visible = false;
                    _tblUpdate.Visible = false;
                }

                else if (_cobSearchCriteria.SelectedValue.ToString().Equals("3"))
                {
                    _tblFyzická.Visible = false;
                    _tblPodnikající.Visible = false;
                    _tblPrávnická.Visible = false;
                    _tblOVM.Visible = true;
                    _tblUpdate.Visible = false;
                }

            }

           
            protected void FillSearchCombo()
            {
                _cobSearchCriteria.Items.Add(new RadComboBoxItem("Fyzická osoba", "0"));
                _cobSearchCriteria.Items.Add(new RadComboBoxItem("Podnikající fyzická osoba", "1"));
                _cobSearchCriteria.Items.Add(new RadComboBoxItem("Právnická osoba", "2"));
                _cobSearchCriteria.Items.Add(new RadComboBoxItem("OVM", "3"));

            }

            #endregion


            # region "User Defined Functions"
            private void GetLoginInformation()
            {
                SPListItemCollection itemsNastaveni = oWebSite.Lists["Nastavení"].Items;

                int iCount = 0;
                foreach (SPListItem itemNastaven in itemsNastaveni)
                {
                    if (iCount == 0)
                    {
                        LoginName1 = itemNastaven["Login"].ToString();
                        Password1 = itemNastaven["Password"].ToString();
                    }
                    iCount++;
                }
            }
            #endregion
            

            #region "Table Function"

            protected void CreateTable(ref Table table)
            {

                TableRow tr = null;
                TableCell td = null;

                Table tblheaderSearch = new Table();
                tblheaderSearch.ID = "TblHeaderSearch";
                AddTableAttributes(ref tblheaderSearch);

                Table tblheaderFyzická = new Table();
                tblheaderFyzická.ID = "TblHeaderFyzická";
                AddTableAttributes(ref tblheaderFyzická);

                Table tblheaderPodnikající = new Table();
                tblheaderPodnikající.ID = "TblHeaderPodnikající";
                AddTableAttributes(ref tblheaderPodnikající);

                Table tblheaderPrávnická = new Table();
                tblheaderPrávnická.ID = "TblHeaderPrávnická";
                AddTableAttributes(ref tblheaderPrávnická);

                Table tblheaderOVM = new Table();
                tblheaderOVM.ID = "TblHeaderOVM";
                AddTableAttributes(ref tblheaderOVM);

                Table tblheaderUpdate = new Table();
                tblheaderUpdate.ID = "TblHeaderUpdate";
                AddTableAttributes(ref tblheaderUpdate);


                switch (table.ID)
                {

                    case "TblFyzická":

                        tr = AddTableRow(ref tblheaderFyzická);
                        AddRowAttributes(0, 0, "", "", "ms-toolbar", ref tr);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "", true, "ms-toolbar", ref td); // To be changed
                        td.Controls.Add(new LiteralControl("<span class='ms-toolbar' style='font-size:13px ; font-weight:bold;'>Fyzická osoba</span>"));
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "right", "", false, "ms-toolbar", ref td);
                        td.Controls.Add(new LiteralControl("<span style='white-space: nowrap;font-size:13px ;padding-right: 3px;' class='ms-descriptiontext'><span class='ms-formvalidation'>*</span>&nbsp;&nbsp;indicates a required field</span>"));
                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 2, 0, "", "", false, "", ref td);
                        td.Controls.Add(tblheaderFyzická);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_lbl1Errors);
     
                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblIDSchránky);
                        td.Controls.Add(new LiteralControl("<span class='ms-formvalidation'> *</span>"));
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txb1IDSchranky);
     
                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblJméno);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txb1Jmeno);
     
                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblPříjmení);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txb1Prijmeni);
          
                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblDatum);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txb1DatumNarozeni);
          
                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblObec);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txb1Obec);
       
                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblUlice);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txb1Ulice);
        
                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblpopisné);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txb1CisloPopisne);
                        
                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblorientační);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txb1CisloOrientacni);
           
                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_btn1Search);

                        break;

                    case "TblPodnikající":

                        tr = AddTableRow(ref tblheaderPodnikající);
                        AddRowAttributes(0, 0, "", "", "ms-toolbar", ref tr);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "", true, "ms-toolbar", ref td); // To be changed
                        td.Controls.Add(new LiteralControl("<span class='ms-toolbar' style='font-size:13px ; font-weight:bold;'>Podnikající Fyzická osoba</span>"));
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "right", "", false, "ms-toolbar", ref td);
                        td.Controls.Add(new LiteralControl("<span style='white-space: nowrap;font-size:13px ;padding-right: 3px;' class='ms-descriptiontext'><span class='ms-formvalidation'>*</span>&nbsp;&nbsp;indicates a required field</span>"));
                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 2, 0, "", "", false, "", ref td);
                        td.Controls.Add(tblheaderPodnikající);



                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_lbl2Errors);
                      
                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblPodIDSchránky);
                        td.Controls.Add(new LiteralControl("<span class='ms-formvalidation'> *</span>"));
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txb2IDSchranky);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblPodIČ);
                        td.Controls.Add(new LiteralControl("<span class='ms-formvalidation'> *</span>"));
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txb2IC);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblPodJméno);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txb2Jmeno);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblPodPříjmení);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txb2Prijmeni);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblPodObec);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txb2ObecMistaPodnikani);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblPodUlice);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txb2UliceMistaPodnikani);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblPodpopisné);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txb2CisloPopisne);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblPodorientační);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txb2CisloOrientacni);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_btn2Search);
                        break;

                    case "TblPrávnická":

                        tr = AddTableRow(ref tblheaderPrávnická);
                        AddRowAttributes(0, 0, "", "", "ms-toolbar", ref tr);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "", true, "ms-toolbar", ref td); // To be changed
                        td.Controls.Add(new LiteralControl("<span class='ms-toolbar' style='font-size:13px ; font-weight:bold;'>Právnická osoba</span>"));
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "right", "", false, "ms-toolbar", ref td);
                        td.Controls.Add(new LiteralControl("<span style='white-space: nowrap;font-size:13px ;padding-right: 3px;' class='ms-descriptiontext'><span class='ms-formvalidation'>*</span>&nbsp;&nbsp;indicates a required field</span>"));
                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 2, 0, "", "", false, "", ref td);
                        td.Controls.Add(tblheaderPrávnická);


                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_lbl3Errors);

                       
                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblPráIDSchránky);
                        td.Controls.Add(new LiteralControl("<span class='ms-formvalidation'> *</span>"));
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txb3IDSchranky);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblPráIČ);
                        td.Controls.Add(new LiteralControl("<span class='ms-formvalidation'> *</span>"));
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txb3IC);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblPráNázev);
                        td.Controls.Add(new LiteralControl("<span class='ms-formvalidation'> *</span>"));
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txb3NazevOrganizace);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_btn3Search);

                        break;

                    case "TblOVM":

       
                        tr = AddTableRow(ref tblheaderOVM);
                        AddRowAttributes(0, 0, "", "", "ms-toolbar", ref tr);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "", true, "ms-toolbar", ref td); // To be changed
                        td.Controls.Add(new LiteralControl("<span class='ms-toolbar' style='font-size:13px ; font-weight:bold;'>OVM</span>"));
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "right", "", false, "ms-toolbar", ref td);
                        td.Controls.Add(new LiteralControl("<span style='white-space: nowrap;font-size:13px ;padding-right: 3px;' class='ms-descriptiontext'><span class='ms-formvalidation'>*</span>&nbsp;&nbsp;indicates a required field</span>"));
                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 2, 0, "", "", false, "", ref td);
                        td.Controls.Add(tblheaderOVM);


                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_lbl4Errors);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblOVMIDSchránky);
                        td.Controls.Add(new LiteralControl("<span class='ms-formvalidation'> *</span>"));
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txb4IDSchranky);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblOVMIČ);
                        td.Controls.Add(new LiteralControl("<span class='ms-formvalidation'> *</span>"));
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txb4IC);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblOVMNázev);
                        td.Controls.Add(new LiteralControl("<span class='ms-formvalidation'> *</span>"));
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txb4Nazevorganizace);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_btn4Search);

                        break;


                    case "TblSearchCriteria":

                         
                                    tr = AddTableRow(ref tblheaderSearch);
                                    AddRowAttributes(0, 0, "", "", "ms-toolbar", ref tr);
                                    td = AddRowCell(ref tr);
                                    AddCellAttributes(0, 0, 0, 0, "", "", true, "ms-toolbar", ref td); // To be changed
                                    td.Controls.Add(new LiteralControl("<span class='ms-toolbar' style='font-size:13px ; font-weight:bold;'>Výběr adresáta a odesílatele</span>"));
                                    td = AddRowCell(ref tr);
                                    AddCellAttributes(0, 0, 0, 0, "right", "", false, "ms-toolbar", ref td);
                                    tr = AddTableRow(ref table);
                                    td = AddRowCell(ref tr);
                                    AddCellAttributes(0, 0, 2, 0, "", "", false, "", ref td);
                                    td.Controls.Add(tblheaderSearch);


                                     tr = AddTableRow(ref table);
                                     td = AddRowCell(ref tr);
                                     AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                                     td.Controls.Add(_lblSchránky);
                                     td = AddRowCell(ref tr);
                                     AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                                     td.Controls.Add(_cobOdesilatel);

                                     tr = AddTableRow(ref table);
                                     td = AddRowCell(ref tr);
                                     AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                                     td.Controls.Add(_chbPredPrijemce);
                                     td = AddRowCell(ref tr);
                                     AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                                     td.Controls.Add(_cobPredPrijemce);

                                     tr = AddTableRow(ref table);
                                     td = AddRowCell(ref tr);
                                     AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                                     td.Controls.Add(_lblSearch);
                                     td = AddRowCell(ref tr);
                                     AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                                     td.Controls.Add(_cobSearchCriteria);
                                      break;
                    case "TblUpdate":

                        tr = AddTableRow(ref tblheaderUpdate);
                        AddRowAttributes(0, 0, "", "", "ms-toolbar", ref tr);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "", true, "ms-toolbar", ref td); // To be changed
                        td.Controls.Add(new LiteralControl("<span class='ms-toolbar' style='font-size:13px ; font-weight:bold;'>Fyzická osoba</span>"));
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "right", "", false, "ms-toolbar", ref td);
                        td.Controls.Add(new LiteralControl("<span style='white-space: nowrap;font-size:13px ;padding-right: 3px;' class='ms-descriptiontext'><span class='ms-formvalidation'>*</span>&nbsp;&nbsp;indicates a required field</span>"));
                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 2, 0, "", "", false, "", ref td);
                        td.Controls.Add(tblheaderUpdate);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0,2,0, "justify", "top", false, "ms-formbody", ref td);
                        td.Controls.Add(_lblSaveError);


                        tr = new TableRow();
                        table.Rows.Add(tr);
                        td = new TableCell();
                        td.CssClass = "ms-formlabel";
                        td.Attributes.Add("nowrap", "true");
                        td.ColumnSpan = 2;
                        td.VerticalAlign = VerticalAlign.Top;
                        td.HorizontalAlign = HorizontalAlign.Justify;
                        td.Controls.Add(_lblSaveSuccess);
                        tr.Cells.Add(td);


                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 2, 0, "justify", "top", false, "ms-formbody", ref td);
                        td.Controls.Add(_lblSaveSuccess);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblnázev);
                        td.Controls.Add(new LiteralControl("<span class='ms-formvalidation'> *</span>"));
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txbNazev);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblVěc);
                        td.Controls.Add(new LiteralControl("<span class='ms-formvalidation'> *</span>"));
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txbVec);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblSkartačnísymbol);
                        td.Controls.Add(new LiteralControl("<span class='ms-formvalidation'> *</span>"));
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_cobSkartacniSymbol);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblNašeč);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txbNasecj);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblNašesp);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txbNaseSpZn);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblVašeč);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txbVasecj);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblVašesp);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txbVaseSpZn);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblKrukám);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txbKRukam);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblDovlastníchrukou);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_chbDoVlastnichRukou);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblZákazdoručenífikcí);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_chbZakazDoruceniFikci);

           
                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblZmocněníčíslo);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txbCisloZakona);

                   
                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblZmocněnírok);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txbRokVydani);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblZmocněníParagraf);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txbParagrafVZakone);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblZmocněnípísmeno);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txbPismeniVOdstavci);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblPoznámka);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_txbPoznamka);

     
                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td.Controls.Add(_lblPřílohy);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_RadUpload1);

                        tr = AddTableRow(ref table);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(190, 0, 0, 0, "", "top", true, "ms-formlabel", ref td);
                        td = AddRowCell(ref tr);
                        AddCellAttributes(0, 0, 0, 0, "", "", false, "ms-formbody", ref td);
                        td.Controls.Add(_btnSave);
                        td.Controls.Add(new LiteralControl("<span>&nbsp;&nbsp</span>"));
                        td.Controls.Add(_btnSend);
                        break;
                }

            }

            private static TableRow AddTableRow(ref Table table)
            {
                TableRow row = new TableRow();
                table.Rows.Add(row);
                return row;
            }

            protected void AddTableAttributes(ref Table table)
            {
                table.CssClass = "ms-toolbar";
                table.Attributes.Add("border", "0");
                table.Attributes.Add("width", "100%");
                table.Style.Add("margin-top", "8");


            }

            protected void AddRowAttributes(int width, int height, string Horizontalalign, string Verticalalign, string css, ref TableRow row)
            {
                if (width > 0)
                    row.Width = width;
                if (height > 0)
                    row.Height = height;
                if (!string.IsNullOrEmpty(css))
                    row.CssClass = css;
                if (!string.IsNullOrEmpty(Horizontalalign))
                {
                    if (Horizontalalign.ToString().ToUpper().Trim().Equals("CENTER"))
                        row.HorizontalAlign = HorizontalAlign.Center;
                    else if (Horizontalalign.ToString().ToUpper().Trim().Equals("JUSTIFY"))
                        row.HorizontalAlign = HorizontalAlign.Justify;
                    else if (Horizontalalign.ToString().ToUpper().Trim().Equals("LEFT"))
                        row.HorizontalAlign = HorizontalAlign.Left;
                    else if (Horizontalalign.ToString().ToUpper().Trim().Equals("RIGHT"))
                        row.HorizontalAlign = HorizontalAlign.Right;
                    else if (Horizontalalign.ToString().ToUpper().Trim().Equals("NOTSET"))
                        row.HorizontalAlign = HorizontalAlign.NotSet;
                }

                if (!string.IsNullOrEmpty(Verticalalign))
                {
                    if (Verticalalign.ToString().ToUpper().Trim().Equals("TOP"))
                        row.VerticalAlign = VerticalAlign.Top;
                    else if (Verticalalign.ToString().ToUpper().Trim().Equals("BOTTOM"))
                        row.VerticalAlign = VerticalAlign.Bottom;
                    else if (Verticalalign.ToString().ToUpper().Trim().Equals("MIDDLE"))
                        row.VerticalAlign = VerticalAlign.Middle;
                    else if (Verticalalign.ToString().ToUpper().Trim().Equals("NOTSET"))
                        row.VerticalAlign = VerticalAlign.NotSet;


                }

            }

            private static TableCell AddRowCell(ref TableRow row)
            {
                TableCell tcell = new TableCell();
                row.Cells.Add(tcell);
                return tcell;
            }

            private void AddCellControl(ref TableCell cell, ref Control control)
            {
                cell.Controls.Add(control);

            }

            protected void AddCellAttributes(int width, int height, int colspan, int rowspan, string Horizontalalign, string Verticalalign, bool wrap, string css, ref TableCell cell)
            {
                if (width > 0)
                    cell.Width = width;
                if (height > 0)
                    cell.Height = height;
                if (colspan > 0)
                    cell.ColumnSpan = colspan;
                if (rowspan > 0)
                    cell.RowSpan = rowspan;

                if (!string.IsNullOrEmpty(css))
                    cell.CssClass = css;

                if (!string.IsNullOrEmpty(Horizontalalign))
                {
                    if (Horizontalalign.ToString().ToUpper().Trim().Equals("CENTER"))
                        cell.HorizontalAlign = HorizontalAlign.Center;
                    else if (Horizontalalign.ToString().ToUpper().Trim().Equals("JUSTIFY"))
                        cell.HorizontalAlign = HorizontalAlign.Justify;
                    else if (Horizontalalign.ToString().ToUpper().Trim().Equals("LEFT"))
                        cell.HorizontalAlign = HorizontalAlign.Left;
                    else if (Horizontalalign.ToString().ToUpper().Trim().Equals("RIGHT"))
                        cell.HorizontalAlign = HorizontalAlign.Right;
                    else if (Horizontalalign.ToString().ToUpper().Trim().Equals("NOTSET"))
                        cell.HorizontalAlign = HorizontalAlign.NotSet;
                }

                if (!string.IsNullOrEmpty(Verticalalign))
                {
                    if (Verticalalign.ToString().ToUpper().Trim().Equals("TOP"))
                        cell.VerticalAlign = VerticalAlign.Top;
                    else if (Verticalalign.ToString().ToUpper().Trim().Equals("BOTTOM"))
                        cell.VerticalAlign = VerticalAlign.Bottom;
                    else if (Verticalalign.ToString().ToUpper().Trim().Equals("MIDDLE"))
                        cell.VerticalAlign = VerticalAlign.Middle;
                    else if (Verticalalign.ToString().ToUpper().Trim().Equals("NOTSET"))
                        cell.VerticalAlign = VerticalAlign.NotSet;

                }

                if (wrap != null)
                {
                    cell.Wrap = wrap;
                }

            }

            protected void AddTableGrid(ref Table table)
            {
                TableRow tr = new TableRow();
                table.Rows.Add(tr);
                TableCell td = new TableCell();
                td.CssClass = "ms-formlabel";
                td.Attributes.Add("nowrap", "true");
                td.Width = 190;
                td.VerticalAlign = VerticalAlign.Top;
                tr.Cells.Add(td);
                td = new TableCell();
                td.CssClass = "ms-formbody";
                td.Controls.Add(_radGrid1);
                tr.Cells.Add(td);
                _radGrid1.Visible = true;

            }


            #endregion


        }
    }


    Regards,
    Marting



  4. Rosen
    Admin
    Rosen avatar
    3237 posts

    Posted 12 Jan 2010 Link to this post

    Hi Martin,

    It seems from the code you have pasted that you are not adding any AjaxSettings. Please refer to this help article for more information on how to add ajax settings programmatically and this one for general information on using RadAjaxManager in MOSS.

    Regards,
    Rosen
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Martin Vesely
    Martin Vesely avatar
    10 posts
    Member since:
    May 2009

    Posted 12 Jan 2010 Link to this post

    Hi,
    Thanks for your support. I tried it and now my code is working fine.

    Keep doing the great work.


    Regards,
    Martin
Back to Top