protected void repTab_ActionNames_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            DataRowView drv = (DataRowView)e.Item.DataItem;
            int campaign_type = Convert.ToInt32(drv["id"]);

            Control divControl = e.Item.FindControl("action_details");

            switch( campaign_type )
            {
                case 1:
                case 2:
                case 17:
                divControl.Controls.Add(new LiteralControl("<span> " + Convert.ToString(drv["user_display_name"]) + "</span>" +
                    "<br><span>Page: " + drv["action_page"] + "</span>"));
                    break;
                case 5:
                case 6:
                case 18: divControl.Controls.Add(new LiteralControl("<span> " + Convert.ToString(drv["user_display_name"]) + "</span>" +
                    "<br><span>Post : <a href='" + drv["val_4"] + "' target='_blank'> "+drv["val_3"]+" </a></span>"));
                    break;
                case 8: divControl.Controls.Add(new LiteralControl("<span><a href='" + drv["val_2"] + "' target='_blank'> Location </a></span>"));
                    break;
                case 9:
                case 10:
                case 19: divControl.Controls.Add(new LiteralControl("<span>" + Convert.ToString(drv["user_display_name"]) + "</span>" +
                    "<br><span>Post Content with hastag </span>"
                    + "<br><span class='bg-info'>@" + drv["val_4"] + " #" +drv["val_2"] + " " + drv["val_3"] + "<bR>" + drv["val_3"] + "</span>"));
                    break;
                case 13: divControl.Controls.Add(new LiteralControl("<span> " + Convert.ToString(drv["user_display_name"]) + "</span>" +
                     "<br><span>Page: " + drv["action_page"] + "</span>"));
                    break;
                case 16: divControl.Controls.Add(new LiteralControl("<span>" + Convert.ToString(drv["user_display_name"]) + "</span>"
                          + "<div class=\"flexslider\"><ul class=\"slides\">"
                          + LoadImageGallery()
                          + "</ul></div>"));
                                break;
            }

            Repeater Repeater2 = (Repeater)e.Item.FindControl("repTab_content");

            string[] headers = new string[1];
            Actions_Reward_To _Actions_Reward_To = new Actions_Reward_To();
            if (SessionState._Campaign.reward_type == 3)
            {
                ;
            }
            else
            {
                string possible_cols_string = _Actions_Reward_To.campaign_settings[campaign_type];
                headers = possible_cols_string.Split(',');
            }

            // get the campaign type settings from database
            string[] setdata = FillData(campaign_type);

            DataTable dt = new DataTable();
            dt.Columns.Add(new DataColumn("header", typeof(string)));
            dt.Columns.Add(new DataColumn("id", typeof(int)));
            dt.Columns.Add(new DataColumn("visiblestate", typeof(bool)));
            dt.Columns.Add(new DataColumn("data", typeof(string)));

            for (int i = 1; i < _Actions_Reward_To.column_headers.Length; i++)
            {
                dt.Rows.Add(_Actions_Reward_To.column_headers[i],
                    i,
                    ((Array.IndexOf(headers, Convert.ToString(i)) > -1) ? true : false),
                    setdata[i]
                    );
            }

            Repeater2.DataSource = dt;
            Repeater2.DataBind();
        }
    }
    private void GetCampaignActionDetails()
    {
        string[] headers = new string[1];
        Actions_Reward_To _Actions_Reward_To = new Actions_Reward_To();
        if (SessionState._Campaign.reward_whom ==3 )
        {
            lnkPickLuckydraw.Visible = true; // display the button for picking the lucky draw user
        }
        else
        {
            string possible_cols_string = _Actions_Reward_To.campaign_objective_settings[SessionState._Campaign.campaign_objective];
            headers = possible_cols_string.Split(',');
        }
        DataTable dt = new DataTable();
        dt.Columns.Add(new DataColumn("header", typeof(string)));
        dt.Columns.Add(new DataColumn("id", typeof(int)));
        dt.Columns.Add(new DataColumn("column_id", typeof(int)));
        dt.Columns.Add(new DataColumn("visiblestate", typeof(bool)));

        for (int i = 1; i < _Actions_Reward_To.column_headers.Length; i++)
        {
            dt.Rows.Add(_Actions_Reward_To.column_headers[i],
                i, i,
                ((Array.IndexOf(headers, Convert.ToString(i)) > -1) ? true : false)
                );
        }

        repTab_header.DataSource = dt;
        repTab_header.DataBind();

        byte ct=0;
        SqlCommand cmd = new SqlCommand("sp_Brand_GetCampaign_Actions");
        cmd.Parameters.AddWithValue("@campaign_id", SessionState._Campaign.campaign_id);
        cmd.Parameters.AddWithValue("@campaign_type", ct);

        ConnObj.GetDataSet(cmd);

        if (ConnObj.IsSuccess && ConnObj.DataSet.Tables.Count > 0 && ConnObj.DataSet.Tables[0].Rows.Count > 0)
        {
            repTab_ActionNames.DataSource = ConnObj.DataSet.Tables[0];
            repTab_ActionNames.DataBind();
        }
    }
    private void GetPossibleActionsForObjective()
    {
        DataTable dt = new DataTable();
        dt.Columns.Add(new DataColumn("header", typeof(string)));
        dt.Columns.Add(new DataColumn("id", typeof(int)));
        dt.Columns.Add(new DataColumn("col_visiblestate", typeof(bool)));
        dt.Columns.Add(new DataColumn("visiblestate", typeof(bool)));
        dt.Columns.Add(new DataColumn("data", typeof(string)));

        string[] headers = new string[1];
        string[] main_headers = new string[1];
        Actions_Reward_To _Actions_Reward_To = new Actions_Reward_To();
        string possible_cols_string = _Actions_Reward_To.campaign_settings[SessionState._Campaign.campaign_objective];
        headers = possible_cols_string.Split(',');

        possible_cols_string = _Actions_Reward_To.campaign_objective_settings[SessionState._Campaign.campaign_objective];
        main_headers = possible_cols_string.Split(',');

        // get the campaign type settings from database
        string[] setdata = FillData(SessionState._Campaign.campaign_objective);

        for (int i = 1; i < _Actions_Reward_To.column_headers.Length; i++)
        {
            dt.Rows.Add(_Actions_Reward_To.column_headers[i],
                i,
                ((Array.IndexOf(main_headers, Convert.ToString(i)) > -1) ? true : false),
                ((Array.IndexOf(headers, Convert.ToString(i)) > -1) ? true : false),
                setdata[i]
                );
        }

        repTab_content.DataSource = dt;
        repTab_content.DataBind();
    }
    private void FillActionRewards()
    {
        string[] headers = new string[1];
        Actions_Reward_To _Actions_Reward_To = new Actions_Reward_To();
        string possible_cols_string = _Actions_Reward_To.campaign_objective_settings[SessionState._Campaign.campaign_objective];
        headers = possible_cols_string.Split(',');

        DataTable dt = new DataTable();
        dt.Columns.Add(new DataColumn("header", typeof(string)));
        dt.Columns.Add(new DataColumn("id", typeof(int)));
        dt.Columns.Add(new DataColumn("column_id", typeof(int)));
        dt.Columns.Add(new DataColumn("visiblestate", typeof(bool)));

        for (int i = 1; i < _Actions_Reward_To.column_headers.Length; i++)
        {
            dt.Rows.Add(_Actions_Reward_To.column_headers[i],
                i, i,
                ((Array.IndexOf(headers, Convert.ToString(i)) > -1) ? true : false)
                );
        }
        repTab_header.DataSource = dt;
        repTab_header.DataBind();
        GetPossibleActionsForObjective();
    }
    protected void FirstPos()
    {
        alreadyexistingactions = new Dictionary<byte, Int64>();

        string[] headers = new string[1];
        Actions_Reward_To _Actions_Reward_To = new Actions_Reward_To();
        if (SessionState._Campaign.reward_type == 3)
        {
            ;
        }
        else
        {
            string possible_cols_string = _Actions_Reward_To.campaign_objective_settings[SessionState._Campaign.campaign_objective];
            headers = possible_cols_string.Split(',');
        }

        DataTable dt = new DataTable();
        dt.Columns.Add(new DataColumn("header", typeof(string)));
        dt.Columns.Add(new DataColumn("id", typeof(int)));
        dt.Columns.Add(new DataColumn("column_id", typeof(int)));
        dt.Columns.Add(new DataColumn("visiblestate", typeof(bool)));

        for (int i = 1; i < _Actions_Reward_To.column_headers.Length; i++)
        {
            dt.Rows.Add(_Actions_Reward_To.column_headers[i],
                i, i,
                ((Array.IndexOf(headers, Convert.ToString(i)) > -1) ? true : false)
                );
        }

        repTab_header.DataSource = dt;
        repTab_header.DataBind();
        GetPossibleActionsForObjective(dt);

        #region set show points controls

        #region get value for show points
        // set reward type details
        SqlCommand cmd = new SqlCommand("sp_Brand_GetCampaignRewardWhen");
        cmd.Parameters.AddWithValue("@campaign_id", Convert.ToInt32(SessionState._Campaign.campaign_id));
        cmd.Parameters.AddWithValue("@brand_id", Convert.ToInt32(SessionState._Campaign.brand_id));
        ConnObj.GetDataSet(cmd);

        #endregion

        // display show points to user control
        if (SessionState._Campaign.reward_type != 3)
        {
            divShowPoints.Visible = true;

            if (ConnObj.IsSuccess && ConnObj.DataSet.Tables.Count > 0 && ConnObj.DataSet.Tables[0].Rows.Count > 0)
            {
                DataRow dr = ConnObj.DataSet.Tables[0].Rows[0];
                drpDisplayRewardDetails.SelectedValue = Convert.ToBoolean(dr["display_reward_to_user"]) == true ? "1" : "0";
                drpAllActionsComp.SelectedValue = Convert.ToBoolean(dr["all_actions_compulsory"]) == true ? "1" : "0";
            }
        }
        else
        {
            if (ConnObj.IsSuccess && ConnObj.DataSet.Tables.Count > 0 && ConnObj.DataSet.Tables[0].Rows.Count > 0)
            {
                DataRow dr = ConnObj.DataSet.Tables[0].Rows[0];
                drpAllActionsComp.SelectedValue = Convert.ToString(dr["all_actions_compulsory"]);
            }
            drpDisplayRewardDetails.SelectedValue = "0";
            lbl_RewardError.Visible = true;
            lbl_RewardError.Text = "No points to set for reward type 'Product'. Continue to view Campaign Summary";
        }

        #endregion
    }
    protected void repTab_ActionNames_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            DataRowView drv = (DataRowView)e.Item.DataItem;
            byte campaign_type = Convert.ToByte(drv["id"]);
            CheckBox chk = (CheckBox)e.Item.FindControl("chk_Action");
            Repeater Repeater2 = (Repeater)e.Item.FindControl("repTab_content");

            string[] headers = new string[1];
            string[] main_headers = new string[1];
            Actions_Reward_To _Actions_Reward_To = new Actions_Reward_To();
            string possible_cols_string = _Actions_Reward_To.campaign_settings[campaign_type];
            headers = possible_cols_string.Split(',');

            possible_cols_string = _Actions_Reward_To.campaign_objective_settings[SessionState._Campaign.campaign_objective];
            main_headers = possible_cols_string.Split(',');

            // get the campaign type settings from database
            string[] setdata = FillData(campaign_type);
            chk.Checked = flg;

            DataTable dt = new DataTable();
            dt.Columns.Add(new DataColumn("header", typeof(string)));
            dt.Columns.Add(new DataColumn("id", typeof(int)));
            dt.Columns.Add(new DataColumn("col_visiblestate", typeof(bool)));
            dt.Columns.Add(new DataColumn("visiblestate", typeof(bool)));
            dt.Columns.Add(new DataColumn("data", typeof(string)));

            for (int i = 1; i < _Actions_Reward_To.column_headers.Length; i++)
            {
                dt.Rows.Add(_Actions_Reward_To.column_headers[i],
                    i,
                    ((Array.IndexOf(main_headers, Convert.ToString(i)) > -1) ? true : false),
                    ((Array.IndexOf(headers, Convert.ToString(i)) > -1) ? true : false),
                    setdata[i]
                    );
            }

            Repeater2.DataSource = dt;
            Repeater2.DataBind();
        }
    }