0

I have two usercontrol U1 and U2. Now in U1 i have one override method(void Commit()) and one public string property(NewCompanyID). From U2 i have to call U1 commit() method and inside the commit method i have to set the NewCompanyID public property.

Code are as follows :
U2 code

 //some code 
obj.Commit();
CompanyId = obj.NewCompanyID;

U1 Code

    public string NewCompanyID
    {
        get
        {
            if (string.IsNullOrEmpty(Convert.ToString(ViewState["NewCompanyId"])))
                return string.Empty;
            return Convert.ToString(ViewState["NewComapnyId"]);
        }
        set
        {
            ViewState["NewCompanyId"] = value;
        }
    }

public override void Commit()

{

    // Some code

    NewCompanyID = results.Entity.Id.ToString();
 }

In Output NewCompanyID is returning blank.

lokusking
  • 7,396
  • 13
  • 38
  • 57
PaOne
  • 13
  • 1
  • Is it possible that `results.Entity.Id` is blank? – Joel Etherton Feb 18 '14 at 14:18
  • `NewComapnyId` is misspelled in your property's `return`. Is that just a typo here, or is that actually in your code? – Manny Feb 18 '14 at 14:31
  • No results.Entity.Id is returning value. – PaOne Feb 18 '14 at 15:12
  • Thanks Manny.It is misspelled but even after that i am not getting NewCompanyId value. Is it possible to get ViewState value of one control from another? – PaOne Feb 20 '14 at 07:35
  • I have got the solution. I was not passing the reference to that usercontrol. Ur answer showed me the way to get the solution. Thanks Manny – PaOne Feb 20 '14 at 08:03

0 Answers0