DBのエントリに基づいて動的にテーブルを作成しています。この作成中に、DBフィールドの1つをに割り当てTable.ID
ます。を使用してテーブルの背景色を変更するにはどうすればよいFindControl(ID)
ですか?
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);
}
}
}
varを使用する代わりに、テーブルのインスタンスを作成して正しい方向に向けました。下記を参照してください:
TableCell tCell = (TableCell)listAgents.FindControl(item.Key);
tCell.BackColor = System.Drawing.Color.Red;
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加