Tuesday, 6 August 2013

How to set the properties for a dynamically created table row?

How to set the properties for a dynamically created table row?

I need to set the border color and border style to a table row that is
dynamically created. How can i do that?
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();
}
}
I also want to display Job Id,Job Description, Job Designation,No Of
vacancies in separate line. How can i achieve that?
Please help me.

No comments:

Post a Comment