0

I passed some data from one form to another form. It's ok. but I can't accessed same data from another method in same form. This is the code (i.e :- StDate,EndDate......SDEvening are my data which I passed from an other form.

public frmLeaveRequestConfirmation(DateTime StDate, DateTime EndDate, string SDFull, Boolean SDMorning, Boolean SDEvening)
{
    //I can Access those data(StDate,EndDateSDFull......) from here
}

private void RequestLeave()
{
    blLeaveManagement bl = new blLeaveManagement();
    dalLeaveManagement dal = new dalLeaveManagement();
    dal.MyProperty_Exception = "";

    dal.MyProperty_LvStartDate = //I want to equal this to StDate;
}

I want to eqaul dal.MyProperty_LvStartDate to StDate. but i can't access to StDate from RequestLeave() method. please somebody give me a solution.

2
  • frmLeaveRequestConfirmation should return variables... Commented Feb 8, 2014 at 14:27
  • How do you call RequestLeave method!! it is better to make it take an argument with the value that you need to use inside it Commented Feb 8, 2014 at 14:40

1 Answer 1

1

Define a variable to store StDate, outside of your method:

DateTime stDate;
public frmLeaveRequestConfirmation(DateTime StDate, DateTime EndDate, string SDFull, Boolean SDMorning, Boolean SDEvening)
{
   stDate = StDate;
   ...
}

Then you can access it from your RequestLeave method.

dal.MyProperty_LvStartDate = stDate;
Sign up to request clarification or add additional context in comments.

1 Comment

I think there should be better way to do this rather than just creating variable, don't you agree

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.