what i have tried.
public class ServerMapper
{
private string _name;
private string _ip;
// Following property is not part of the database table and will be only used in the UI.
private string _status;
public ServerMapper(string Name, string IP)
{
this.Name = Name;
this.IP = IP;
public string Name
{
get { return this._name; }
set { this._name = value; }
}
public string IP
{
get{ return this._ip; }
set{ this._ip = value; }
}
}
MainViewModel class
private void InitServerState(List
{
//foreach (DataGridRow row in dgServer)
//{ I have to iterate here
//
foreach (ServerMapper item in serverMapCol)
{
{
var get_count = (from a in this.db.Servers
from component in this.db.Components
where a.ServerID == component.ServerID && component.State == "Stopped"
select a).Count();
var serverstate = (from a in this.db.Servers
where a.PingStatus == "online" && a.ServerAgentStatus == "running"
select a).Any();
if (get_count == 0 && serverstate)
{
item.Status = "ok";
}
else if (get_count == 2 && serverstate)
{
item.Status = "critical";
}
else
{
item.Status = "warning";
}
}
}
}
and I will bind this value of `Status` to my datagrid as
but this above code computes the value of Status for all the datagrid rows instead for each row. how to over come this ?
Replies
Know the answer? Post it — somebody with the same question will find it here.