我需要將邊框顏色和邊框樣式設置爲動態創建的表格行。我怎樣才能做到這一點?如何設置動態創建的表格行的屬性?
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,職位描述,職位名稱,職位空缺編號。我怎麼能做到這一點?
請幫幫我。
: -
關於第二個問題: 要顯示在單獨一行,用於顯示CSS前塊,使每個項目將出現在新行? – Arshad