According to this: https://documentation.devexpress.com/#AspNet/CustomDocument5762 the ASPxHiddenField supports all lists that implements the IList interface.
I created the following class in order to use a List<logItem> of them and pass it to the ASPxHiddenField, but when I try to use it the application throws an error. I had to implement a string representation of the objects and created a list of type: List<string>, using this approach I'm able to send and receive the List<string> using the ASPxHiddenField.
¿Is this the only way or can I use directly the List<logItem> object with the ASPxHiddenField?
C#public class logItem
{
public int errorCode { get; set; }
public string key { get; set; }
public string Description { get; set; }
public DateTime timeStamp { get; set; }
public logItem(int _errorCode, string _key, string _Description)
{
this.errorCode = _errorCode;
this.key = _key;
this.Description = _Description;
this.timeStamp = DateTime.Now;
}
public logItem(string rep)
{
var arr = rep.Split('|');
errorCode = int.Parse(arr[0]);
key = arr[1];
Description = arr[2];
timeStamp = DateTime.Parse(arr[3]);
}
public override string ToString()
{
return string.Format("{0}|{1}|{2}|{3}", errorCode, key, Description, timeStamp);
}
}
//-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
//Trying to use the ASPxHiddenField
System.Collections.Generic.List<string> errorsList = new System.Collections.Generic.List<string>();
//Changed to string representation
errorsList.Add(new UserControls.logItem(1, "mat1", "material 1").ToString());
errorsList.Add(new UserControls.logItem(2, "mat2", "material 2").ToString());
errorsList.Add(new UserControls.logItem(3, "mat3", "material 3").ToString());
ASPxHiddenFieldErrors.Set("ErrorsList", errorsList);
//-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
//Reading the ASPxHiddenField
var param = (List<string>)hiddenFieldErrorList.Get("ErrorsList");
Hello Guillermo,
Thank you for your code. I reproduced the same behavior on my side and passed this information to our developers to analyze. We will research it and answer you once we get any result. In the meantime, you can use a workaround with the string conversion.
I see you are using version 12.2.18. Please also note that if we find a way to solve the problem, the update to the newest version of our controls will be required.