public void updateCampaignDetailsTab()
        {
            try
            {
                CampaignMasterPrimaryKey objCampaignMasterPrimaryKey = new CampaignMasterPrimaryKey(Convert.ToInt64(hiddenCampaignID.Value));
                objCampaignMaster = CampaignMaster.SelectOne(objCampaignMasterPrimaryKey, ConnectionString);
                DataTable campMaster = CampaignMasterBase.SelectByName("CampaignName", txtCampaignName.Text.ToString(), ConnectionString);
                if (campMaster.Rows.Count == 0)
                {
                    objCampaignMaster.CampaignName = txtCampaignName.Text;
                }
                else
                {
                    txtCampaignName.Text = objCampaignMaster.CampaignName;
                }
                objCampaignMaster.FromAddress = ddlFromAddress.SelectedItem.Text;
                objCampaignMaster.FromName = txtFromName.Text.ToString().Trim();
                objCampaignMaster.CampaignDescription = txtCampaignDescription.Text;
                objCampaignMaster.ReplytoAddress = txtReplytoAddress.Text;
                objCampaignMaster.ReplaytoName = txtReplaytoName.Text;
                objCampaignMaster.Subject = txtSubject.Text;
                objCampaignMaster.TrackReads = chkTrackReads.Checked;
                if (RadEditor1.Content.ToString().Trim().Length != 0)
                    objCampaignMaster.htmlHasUnsubLink = chkAddress.Checked;
                else
                    objCampaignMaster.htmlHasUnsubLink = false;
                if (textRadEditor.Content.ToString().Trim().Length != 0)
                    objCampaignMaster.txtHasUnsubLink = chkTxtAddress.Checked;
                else
                    objCampaignMaster.txtHasUnsubLink = false;


                objCampaignMaster.ModifiedDate = DateTime.Now;
                if (txtUnsubscribe.Text != string.Empty)
                {
                    hdUnsubscribeText.Value = lblunsubinfo.Text;
                    hdUnsubscribeLinkText.Value = lblunsublinktext.Text;
                    objCampaignMaster.UnsubscribeText = txtUnsubscribe.Text;
                    objCampaignMaster.UnsubscribeLinkText = DDLinktext.SelectedItem.Text;
                    lblunsubinfo.Text = txtUnsubscribe.Text;
                    lblunsublinktext.Text = DDLinktext.SelectedItem.Text;
                    DivUnsubtext.InnerHtml = lblunsubinfo.Text + " \n" + lblunsublinktext.Text;
                }
                //Bellow code is used to insert or Update assigned Campaign details in to CampaignMailing Table
                bool mailingInstStatus = false;
                if (hdCampMailingFlag.Value == "1")
                {
                    CampaignMailingBase objCampaignMailingBase = new CampaignMailingBase(ConnectionString);
                    if (AssCampIdDb.Value.ToString().Length != 0 && AssCampIdDb.Value != null)
                    {
                        if (objCampaignMailingBase.checkAssignedCampaignId(Convert.ToInt64(hiddenCampaignID.Value), Convert.ToInt64(AssCampIdDb.Value.ToString()), ConnectionString))
                        {
                            mailingInstStatus = objCampaignMailingBase.UpdateAssignedCampaignId(Convert.ToInt64(hiddenCampaignID.Value), (ddlCampsNames.SelectedItem.Text != defaultListItem) ? Convert.ToInt64(ddlCampsNames.SelectedItem.Value) : 0, ConnectionString);
                        }
                        else if (ddlCampsNames.SelectedItem.Text != defaultListItem)
                        {
                            CampaignMailing objCampaignMailing = new CampaignMailing(ConnectionString);
                            objCampaignMailing.CampaignId = Convert.ToInt64(hiddenCampaignID.Value);
                            objCampaignMailing.CampaignsID = Convert.ToInt64(ddlCampsNames.SelectedItem.Value);//Mailing Id
                            objCampaignMailing.CreatedDate = DateTime.Now;
                            objCampaignMailing.ModifiedDate = DateTime.Now;
                            objCampaignMailing.IsActive = true;
                            mailingInstStatus = objCampaignMailing.Insert();
                        }
                    }
                }

                if (hdCampMailingFlag.Value == "1" && mailingInstStatus == true)
                {
                    if (ddlCampsNames.Text != defaultListItem)
                        objCampaignMaster.AssignedCampaignID = Convert.ToInt64(ddlCampsNames.SelectedItem.Value);
                    else
                        objCampaignMaster.AssignedCampaignID = 0;
                    objCampaignMaster.UpdateCampaignDetails();
                }
                else
                {
                    objCampaignMaster.UpdateCampaignDetails();
                }

                checkCampaignStatus();
                hdCampDetailsTab1.Value = "0";
                lblCampName.Text = txtCampaignName.Text.Trim();
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
        protected void lbtnAssigncampaigntomailing_Click(object sender, EventArgs e)
        {
            objCampaignMaster = new CampaignMaster(ConnectionString);
            if (RgrdSentCampaigns.MasterTableView.Items.Count > 0)
            {
                //Get contact Selection
                rememberContactSelectionForSent("SgrdaddchkSelectRecs", "lblSCampaignId", RgrdSentCampaigns, "Sgrdaddselectall");
                if (ViewState["SentSelectedContacts"] != null)
                {
                    StringBuilder strbEditContacts = new StringBuilder();
                    //adding selected contatIds to stringbuilder
                    for (int i = 0; i < contactsSelected.Count; i++)
                    {
                        strbEditContacts.Append(contactsSelected[i] + ", ");
                        //Bellow code is used to insert or Update assigned Campaign details in to CampaignMailing Table
                        bool mailingInstStatus = false;
                        CampaignMailingBase objCampaignMailingBase = new CampaignMailingBase(ConnectionString);
                        if (ddlCampaigns.SelectedItem.Text != defaultListItem)
                        {
                            if (objCampaignMailingBase.checkAssignedCampaignsId(Convert.ToInt64(contactsSelected[i]), ConnectionString))
                            {
                                mailingInstStatus = objCampaignMailingBase.UpdateAssignedCampaignId(Convert.ToInt64(contactsSelected[i]), (ddlCampaigns.SelectedItem.Text != defaultListItem) ? Convert.ToInt64(ddlCampaigns.SelectedItem.Value) : 0, ConnectionString);
                            }
                            else if (ddlCampaigns.SelectedItem.Text != defaultListItem)
                            {
                                CampaignMailing objCampaignMailing = new CampaignMailing(ConnectionString);
                                objCampaignMailing.CampaignId = Convert.ToInt64(contactsSelected[i]);
                                objCampaignMailing.CampaignsID = Convert.ToInt64(ddlCampaigns.SelectedItem.Value);//Mailing Id
                                objCampaignMailing.CreatedDate = DateTime.Now;
                                objCampaignMailing.ModifiedDate = DateTime.Now;
                                objCampaignMailing.IsActive = true;
                                mailingInstStatus = objCampaignMailing.Insert();
                            }
                        }
                        if (mailingInstStatus == true)
                        {
                            //get campaign details
                            CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(contactsSelected[i]));
                            objCampaignMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(pk, ConnectionString);

                            if (ddlCampaigns.Text != defaultListItem)
                                objCampaignMaster.AssignedCampaignID = Convert.ToInt64(ddlCampaigns.SelectedItem.Value);
                            else
                                objCampaignMaster.AssignedCampaignID = 0;

                            objCampaignMaster.UpdateCampaignDetails();
                        }

                    }
                    if (ddlCampaigns.SelectedItem.Text != defaultListItem)
                    {
                        strbEditContacts.Remove(strbEditContacts.Length - 2, 1);
                        ViewState["SentSelectedContacts"] = null;
                        hdrchkselected.Clear();
                        if (txtSentMailID.Text != string.Empty || txtSentmailSearch.Text != string.Empty)
                        {
                            SearchCriteria("", 0, 0);
                        }
                        else
                        {
                            bindGrid(string.Empty, 0);
                            bindCampNames();
                        }
                        lblMainMsg.ForeColor = System.Drawing.Color.Green;
                        lblMainMsg.Text = "Campaign to selected mailings(with ids: " + strbEditContacts.ToString() + ")assigned successfully!";
                    }
                }
            }
        }