DHCPサーバーからの構成データがあり、次のようなクラスに入れています。
public class DHCP
{
public DHCP()
{
this.Scopes = new List<Scope>();
}
public List<Scope> Scopes;
public class Scope
{
public Scope(string ScopeAddress, string SubnetMask, string State, string ScopeName, string Comment)
{
this.ScopeAddress = ScopeAddress;
this.SubnetMask = SubnetMask;
this.State = State;
this.ScopeName = ScopeName;
this.Comment = Comment;
}
public Scope(string ScopeAddress, string SubnetMask, string State, string ScopeName, string Comment, bool initClients)
{
this.ScopeAddress = ScopeAddress;
this.SubnetMask = SubnetMask;
this.State = State;
this.ScopeName = ScopeName;
this.Comment = Comment;
if (initClients)
this.Clients = new List<Client>();
}
public void InitClients()
{
this.Clients = new List<Client>();
}
public void InitReservations()
{
this.Reservations = new List<Reservation>();
}
public string ScopeAddress { get; set; }
public string SubnetMask { get; set; }
public string State { get; set; }
public string ScopeName { get; set; }
public string Comment { get; set; }
public List<Client> Clients;
public List<Reservation> Reservations;
}
public class Client
{
public Client(string IPAddress, string SubnetMask, string UniqueID, string LeaseExpires, string ClientType)
{
this.IPAddress = IPAddress;
this.SubnetMask = SubnetMask;
this.UniqueID = UniqueID;
this.LeaseExpires = LeaseExpires;
this.ClientType = ClientType;
}
public string IPAddress { get; set; }
public string SubnetMask { get; set; }
public string UniqueID { get; set; }
public string LeaseExpires { get; set; }
public string ClientType { get; set; }
public Reservation ClientReservation { get; set; }
}
public class Reservation
{
public Reservation(string IPAddress, string UniqueID, bool ReservationActive)
{
this.IPAddress = IPAddress;
this.UniqueID = UniqueID;
this.ReservationActive = ReservationActive;
}
public string IPAddress { get; set; }
public string UniqueID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string Type { get; set; }
public bool ReservationActive { get; set; }
}
}
次に、グリッドビューList<DHCP.Client>
で使用するを使用しDataSource
ます。データフィールドの1つをに設定するとClientReservation.ReservationActive
、見つからないというエラーが発生します。
私はこれをList<>で試しましたが、これはNULLデータではありません。だから私は質問しなければなりません:
これはまったくできますか?オブジェクトがある場合、エラーなしでClient.ClientReservation == null
それをどのように処理できますか?DataBind()