0
我根據數據庫中的條目動態創建表。在創建期間,我將其中一個DB字段分配給Table.ID
。如何通過使用FindControl(ID)
來更改表格的背景顏色?通過FindControl更改表backcolor
protected void AgentStat_Tick(object sender, EventArgs e)
{
Dictionary<string, string> activityAgent = new Dictionary<string, string>();
string conString = "Data Source = lewcomp1\\COMPLIANCE; Initial Catalog = 3CXCallStats; Integrated Security = True;";
string query = "SELECT FirstName, LastName, Status FROM Queue_Listing WHERE [ComplianceCC(English)] = 'True'";
SqlConnection myCon = new SqlConnection(conString);
SqlCommand cmd = new SqlCommand(query, myCon);
SqlDataReader myReader;
myCon.Open();
myReader = cmd.ExecuteReader();
while (myReader.Read())
{
string name = myReader["FirstName"].ToString();
string surname = myReader["LastName"].ToString();
string status = myReader["Status"].ToString();
activityAgent.Add(name + surname.Substring(0, 1), status);
}
foreach (KeyValuePair<string, string> item in activityAgent)
{
if (item.Value == "Connected")
{
var state = listAgents.FindControl(item.Key);
}
}
}
你能後的HTML代碼' ListAgents'? – SpiderCode
ListAgents是一個ID爲空的div。用作容器 –
請看看我發佈的答案。 – SpiderCode