CipherIS
asked on
ASP.NET - Having issues with value in a class - not changing
I have a Session["AccessKey"]. I am passing the value to a Class "CustomerAccessKey". Then I call FileList.getFiles to bind it to the repeater. In this class I need the "CustomerAccessKey" value.
When i run the website the first time and use key "1234" it gets the data correctly.
I log out.
Log back in and have key = "3456".
I see it being set in "CustomerAccessKey" as "3456" but in FileList.GetFiles the CustomerAccessKey = "1234".
How do I fix?
When i run the website the first time and use key "1234" it gets the data correctly.
I log out.
Log back in and have key = "3456".
I see it being set in "CustomerAccessKey" as "3456" but in FileList.GetFiles the CustomerAccessKey = "1234".
How do I fix?
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
//Access Key
CustomerAccessKey.getCustomerAccessKey = Session["AccessKey"].ToString();
//Get Files
rptFiles.DataSource = FileList.getFiles;
rptFiles.DataBind();
}
}
public class FileList
{
static FileList()
{
IMDRTransferService _getFiles = new MDRTransferServiceClient();
getFiles = new List<Files>();
foreach (var files in
_getFiles.CustomerFiles(CustomerAccessKey.getCustomerAccessKey))
{
getFiles.Add(new Files() { FileName = files.FileName,
DisplayName = files.DisplayName });
}
}
public static List<Files> getFiles { get; set; }
}
public class Files
{
public string FileName { get; set; }
public string DisplayName { get; set; }
}
public class CustomerAccessKey
{
public static string getCustomerAccessKey { get; set; }
}
ASKER
remove the keyword static? can you give me a code sample of how to fix?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Its not working. Now its worse. i'm not receiving any data.
ASKER
I don't know what happened but it seems to be working now. Thx
When you make the call to FileList For very first time(ie. during first login with 1234 id), the constructor gets called and file list is loaded.
Any furthur calls to get files will never call the static constructor.
If you want to load files again, create a method in the FileList Class namely getFiles and return FilList for this new accesskey....