I'm building a dynamic GRIDVIEW, where the information for each TD will be a DIV.
exemplo: <td><div id="d1" class="redips-drag t1">z</div></td>
I'm filling in the variant as follows:
if (dtWorkServiceTimeByWorkerAndDate.Rows.Count > 0)
finalResult = "<div id=\"column" + count.ToString() + "\" class=\"redips-drag t1\">" + formatSecondsInHourAndMinute(Convert.ToInt32(dtWorkServiceTimeByWorkerAndDate.Rows[0]["work_ServiceTime"])) + "</div>";
My problem is that GRID does not recognize the div as an object, but as a String. The value of each column is coming out as follows:
exemplo <div id="column1" class="redips-drag t1">23:59</div>
Does anyone know how I can do this to avoid this problem?
Vlw.
EDIT
To build the grid, I'm using a function that returns a DataTable, as follows:
public DataTable constructWorkerAvailabilityTime()
{
DateTime fDateDataType = new DateTime(Int32.Parse(fYear), Int32.Parse(fMonth), Int32.Parse(fDay));
DateTime tDateDataType = new DateTime(Int32.Parse(tYear), Int32.Parse(tMonth), Int32.Parse(tDay));
this.fromDate = fDateDataType.ToString("yyyy-MM-dd");
this.toDate = tDateDataType.ToString("yyyy-MM-dd");
DataTable dtFinalResult = new DataTable();
List<String> allWorkers = getAllWorkers();
List<String> columnsSequence = getDateColumnsSequence();
dtFinalResult.Columns.Add("worker", typeof(string));
int count = 0;
foreach (string column in columnsSequence)
dtFinalResult.Columns.Add(column, typeof(string));
foreach (string worker in allWorkers)
{
DataRow newRow = dtFinalResult.NewRow();
newRow["worker"] = getWorkerName(worker);
foreach (string column in columnsSequence)
{
HtmlString htmlString = getWorkServiceTimeByWorkerAndDate(worker, column, count);
newRow[column] = htmlString;
//newRow[column] = "@Html.Raw(" + getWorkServiceTimeByWorkerAndDate(worker, column, count) + ")";
count++;
}
dtFinalResult.Rows.Add(newRow);
}
return dtFinalResult;
}
private HtmlString getWorkServiceTimeByWorkerAndDate(string worker, string executionDate, int count)
{
HtmlString finalResult = new HtmlString("");
DataTable dtWorkServiceTimeByWorker = cmd.selectWorkServiceTimeByWorker(worker);
DataTable dtWorkServiceTimeByWorkerAndDate = cmd.selectWorkServiceTimeByWorkerAndDate(worker, executionDate);
if (dtWorkServiceTimeByWorker.Rows.Count == 1)
finalResult = new HtmlString("<div id=\"column" + count.ToString() + "\" class=\"redips-drag t1\" runat=\"server\">" + formatSecondsInHourAndMinute(Convert.ToInt32("28860")) + "</div>");
else if (dtWorkServiceTimeByWorker.Rows.Count > 1)
{
if (dtWorkServiceTimeByWorkerAndDate.Rows.Count > 0)
finalResult = new HtmlString("<div id=\"column" + count.ToString() + "\" class=\"redips-drag t1\" runat=\"server\">" + formatSecondsInHourAndMinute(Convert.ToInt32(dtWorkServiceTimeByWorkerAndDate.Rows[0]["work_ServiceTime"])) + "</div>");
else
finalResult = new HtmlString("<div id=\"column" + count.ToString() + "\" class=\"redips-drag t1\" runat=\"server\">00:00</div>");
}
return finalResult;
}
And finally I fill the grid in the Load page:
protected void Page_Load(object sender, EventArgs e)
{
WorkerManagement wm = new WorkerManagement();
GridWorkerAvailability.DataSource = wm.constructWorkerAvailabilityTime();
GridWorkerAvailability.DataBind();
GridWorkerAvailability.SelectedIndex = -1;
}