Pass variable from 1 section of code to another

Hi
Can anyone tell me how I can get the value of strOrderNumber to display in lblDisplayOrderNumber.Text
lblDisplayOrderNumber is in a different panel to strOrderNumber.

Regards
Caz

private void btnProceed_Click(object sender, System.EventArgs e)
{
// code
strOrderNumber = "Order number" + " " + sqlComRetrieveOrderNumber.Parameters["@RETURN_VALUE"].Value.ToString();
}

private void btnCheckDetails_Click(object sender, System.EventArgs e)
{
lblDisplayOrderNumber.Text = strOrderNumber;
}
BeginningWebDesignAsked:
Who is Participating?
 
djhoenConnect With a Mentor Commented:
When you say that lblDisplayOrderNumber is in a different panel to strOrderNumber, does that mean that they are in a different form or the same form?

If they are on the same form you would just need to make strOrderNumber a class variable.

If they are on a different form, you could create a property for your strOrderNumber like so:

public StrOrderNumber
{
  get
  {
    return strOrderNumber;
  }
  set
  {
    strOrderNumber = value;
  }
}

you would need to add a reference to the form that has the strOrderNumber in the constructor - like so:

form2(form1 f1)
{
  //class logic
 
  f1.StrOrderNumber = value;
}
0
 
vinhnlCommented:
what you mean?-->lblDisplayOrderNumber is in a different panel to strOrderNumb
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.