Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8567259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:50:28+00:00 2026-06-11T17:50:28+00:00

I have a problem where I am getting an id from a selected checkbox,

  • 0

I have a problem where I am getting an id from a selected checkbox, then it sends it to a delete method and it then passes the id to a stored procedure. The problem I am having though is it is returning my id in a wrong format (“232,4323”) instead of (“232″,”4323”) so when it comes to passing in values to the stored procedure, it craps out because of the string format.
Here is my code in the aspx.

function doTheDelete(doIDeleteTimeTracker) {
    var selectedTimeTrackerList = getSelectedTimeTrackerIDs();
    if (selectedTimeTrackerList.length > 0) {
        $.ajax({
            type: "POST",
            //url: "/Tasks/ViewTasks.aspx/deleteTasksAndLinkedItems",
            url: '<%=ResolveUrl("~/TimeTrackers/ViewTimeTrackers.aspx/deleteSelectedTimeTracker")%>',
            data: "{'DeleteTimeTracker' : '" + doIDeleteTimeTracker + "'," + "'TimeBill': ['" + selectedTimeTrackerList.join(',') + "']}",
            //dataaaaaa
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (data) {
                var ss = data.d;
                if (ss.length > 0) {
                    for (var i = 0; i < ss.length; ++i) {
                        $.noty.consumeAlert({ layout: 'center', type: 'error', dismissQueue: true });
                        alert(ss[i]);
                    }
                }
                $("#viewTimeTrackersGrid").flexReload();
                showMessage('Successfully Removed Time Tracker');
            },
            error: function (data) {
                $.noty.consumeAlert({ layout: 'center', type: 'error', dismissQueue: true, modal: true });
                alert('Error Deleting Time Tracker');
                if (window.console) {
                    console.log(data);
                }
            }
        });
    } else {
        showMessage('No time tracker(s) are selected.');
    }
}

and here is my delete method in the code behind.

public static string[] deleteSelectedExpense(bool DeleteExpenses, String[] ExpId)
{
    var rList = new List<string>();
    //var canDeleteTasks = false;
    //var canDeleteTrackers = false;
    var canDeleteExpenses = false;
    var investigatorID = (int)HttpContext.Current.Session["InvestigatorID"];
    var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connect"].ToString());
    var cmd = new SqlCommand("p_Admin_Permissions_CanDeleteExpenses", conn);
    cmd.Parameters.Add(new SqlParameter("@InvestigatorID", SqlDbType.Int));
    cmd.Parameters["@InvestigatorID"].Value = investigatorID;
    cmd.CommandType = CommandType.StoredProcedure;
    try
    {
        conn.Open();
        canDeleteExpenses = (bool)cmd.ExecuteScalar();
    }
    catch (SqlException sql)
    {
        if (!rList.Contains("Can not connect to the database. Please try again."))
            rList.Add("Can not connect to the database. Please try again.");
    }
    catch (Exception ex)
    {
        if (!rList.Contains("An Error Occured"))
            rList.Add("An Error Occured");
    }
    finally
    {
        if (conn.State == ConnectionState.Open)
            conn.Close();
    }

    if (canDeleteExpenses)
    {
        foreach (var expense in ExpId)// expense ends up beng ("232,423") instead of just taking 1 string at a time ("232").....("423")...
        {

            if (canDeleteExpenses)
            {
                conn = new SqlConnection(ConfigurationManager.ConnectionStrings["OSCIDConnectionString"].ToString());
                cmd = new SqlCommand("p_CaseFiles_Expenses_DeleteExpenses", conn);
                cmd.Parameters.Add(new SqlParameter("@ExpID", SqlDbType.Int));
                cmd.Parameters["@ExpID"].Value = int.Parse(expense);
                cmd.Parameters.Add("@Message", SqlDbType.NVarChar, 50);
                cmd.Parameters["@Message"].Direction = ParameterDirection.Output;
                cmd.CommandType = CommandType.StoredProcedure;
                try
                {
                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
                catch (SqlException sql)
                {
                    if (!rList.Contains("Error Connecting to the Database. Unable To Delete Expense(s)."))
                        rList.Add("Error Connecting to the Database. Unable To Delete Expense(s).");
                }
                catch (Exception ex)
                {
                    if (!rList.Contains("An Error Occured"))
                        rList.Add("An Error Occured");
                }
                finally
                {
                    if (conn.State == ConnectionState.Open)
                        conn.Close();
                }
            }
            else if (!canDeleteExpenses)
            {
                rList.Add("You do not have permission to delete Expenses");
            }
            else
            {
                if (!rList.Contains("You do not have permission to delete the Expense(s)."))
                    rList.Add("You do not have permission to delete the Expense(s).");
            }
        }
    }
    return rList.ToArray();
}

I am guessing it could be in the “Data :” in the ajax call formatting for the array(I’ve tried a few things)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:50:29+00:00Added an answer on June 11, 2026 at 5:50 pm

    thanks for the help gents. I managed to fix it. Solution was to do this:

     "'ExpId': ['" + selectedExpensesList.join('\',\'') + "']}",
    

    instead of :

     "'ExpId': ['" + selectedExpensesList.join(',') + "']}",
    

    adding the extra ‘ seemed to work. It then manages to take each id seperately instead of taking the entire array and pooping on me

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with getting a class from an external .jar file. I
I have a problem with getting jquery to retrieve results from a WCF service.
I'm new to SQL. I have a simple problem with getting the results from
I have a problem getting a private method using reflection. Even with BindingFlags.NonPublic and
I have problem with getting values from select option when use JQuery UI $('#id').combobox().
I am having a problem getting a result set from my Sql Server 2008
I have a problem with getting the pixels from an image. I load a
I have a problem with getting selected objectfrom my list. I bind collection of
I just started a graphical C++ course and I have problem getting an overview
I have a problem getting password_Reset_confirm bit working. url: (r'^password_reset/$', 'django.contrib.auth.views.password_reset'), (r'^password_reset_done/$', 'django.contrib.auth.views.password_reset_done'), (r'^password_reset_confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$',

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.