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

  • SEARCH
  • Home
  • 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 6937423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:21:39+00:00 2026-05-27T12:21:39+00:00

I am am trying to pass a parameter into my textbox which communicates to

  • 0

I am am trying to pass a parameter into my textbox which communicates to my database and runs a stored procedure on a button click.

I have the button working if I hard code a parameter value but I need to to accept parameters in a textbox.

Any ideas how I can fix this code to accomplish this?

This is one of my classes

public FixPayrollMonth PayrollMonth()
{
    return StoreProcPayrollMonth("fix_Payroll_PayingMonth");
}

private FixPayrollMonth StoreProcPayrollMonth(string storeprocedurename)
{
    FixPayrollMonth result = new FixPayrollMonth() {IsSuccess = false };
    SqlCommand cmd = new SqlCommand(storeprocedurename, Connection);
    cmd.Parameters.Add(new SqlParameter("@Month_Change", 123456 ));         
    cmd.CommandType = System.Data.CommandType.StoredProcedure;
    cmd.Connection.Open();

    using (var data = cmd.ExecuteReader())
    {
        while (data.Read())
        {
            result.MonthChanged = Convert.ToInt32(data["MonthChanged"]);
            result.IsSuccess = Convert.ToBoolean(data["IsSuccess"]);
        }
    }
    return result;
}

This is my button click…I need to link it to my textbox called txtPay

protected void btnFixMnth_Click(object sender, EventArgs e)
{
    var result = repo.PayrollMonth();
    if (result.IsSuccess)
    {
        lblMessageBoxMnthChg.Text = "Succesful Month has been changed to: " + result.MonthChanged;
    }
    else
    {
        lblMessageBoxMnthChg.Text = "Failed to change month";
    }
}
  • 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-05-27T12:21:40+00:00Added an answer on May 27, 2026 at 12:21 pm

    Your call to repo.PayrollMonth would required a parameter to pass in the value of the textbox. So in your button click event you would do:

     var result = repo.PayrollMonth(txtPay.Text);
    

    And you repo would need to be modified to look like the following:

     public FixPayrollMonth(string pay)
     {
          StoreProcPayrollMonth("fix_Payroll_PayingMonth", pay);
    }
    
    private FixPayrollMonth StoreProcPayrollMonth(string storeprocedurename, string pay)
    {
        FixPayrollMonth result = new FixPayrollMonth() {IsSuccess = false };
        SqlCommand cmd = new SqlCommand(storeprocedurename, Connection);
        cmd.Parameters.Add(new SqlParameter("@Month_Change", pay ));         
        cmd.CommandType = System.Data.CommandType.StoredProcedure;
        cmd.Connection.Open();
    
    
    
        using (var data = cmd.ExecuteReader())
        {
            while (data.Read())
            {
                result.MonthChanged = Convert.ToInt32(data["MonthChanged"]);
                result.IsSuccess = Convert.ToBoolean(data["IsSuccess"]);
            }
        }
    
        return result;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying pass a Hashtable as parameter into a method which itself passes
I have a Stored Procedure (SP) in which I pass in one value. In
I am trying to pass in a function as a parameter: GEvent.addListener(marker_1, click, populateMarkerWindow(0,
Does anyboy know how to pass the LastChangeNumber parameter into MSBuild? I'm trying to
I'm trying to pass a parameter from php into my javascript function inside html.
I am trying to pass array parameter to SQL commnd in C# like below,
I'm using a repeater control and I'm trying to pass a parameter as such:
I'm trying to pass a null value for the first parameter in the code
I'm trying to pass value by using EL expression in get request parameter, but
I'm trying to pass parameters to my static web method (which is in an

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.