我需要将边框颜色和边框样式设置为动态创建的表格行。我怎样才能做到这一点?
if (cmd.Connection.State == ConnectionState.Closed)
cmd.Connection.Open();
using (SqlDataReader reader = cmd.ExecuteReader())
{
if (reader.HasRows)
{
while (reader.Read())
{
JobDesignation = reader.GetString(0);
JobDescription = reader.GetString(1);
NoOfVacancies = Convert.ToString(reader.GetInt32(2));
DatePosted = Convert.ToString(reader.GetDateTime(3)).Replace("00:00:00", "");
jobId = reader.GetString(4);
int tblRows = 1;
int tblCols = 1;
Table tbl = new Table();
PlaceHolder1.Controls.Add(tbl);
for (int i = 0; i < tblRows; i++)
{
TableRow tr = new TableRow();
for (int j = 0; j < tblCols; j++)
{
TableCell tc = new TableCell();
System.Web.UI.WebControls.Label lblBox = new System.Web.UI.WebControls.Label();
lblBox .Text = "Job ID:" + jobId + Environment.NewLine + "Job Designation:" + JobDesignation + Environment.NewLine + "Job Description:" + JobDescription + Environment.NewLine + "Vacancies:" + NoOfVacancies + Environment.NewLine + "Ad Posted On:" + DatePosted + "";
tc.Controls.Add(lblBox);
tr.Cells.Add(tc);
}
tr.Width = new Unit("700px");
tr.Height = new Unit("200px");
tr.BorderColor = System.Drawing.Color.Black;
tr.BorderStyle = System.Web.UI.WebControls.BorderStyle.Solid;
tbl.Rows.Add(tr);
}
ViewState["dynamictable"] = true;
} reader.NextResult();
}
}
我还想在单独的行中显示职位 ID、职位描述、职位名称、职位空缺数。我怎样才能做到这一点?
请帮我。