protected void FillTable() { DataTable dt = new DataTable(); if (selectCampusToView.Items.Count > 0) { ReservationData reservationData = new ReservationData(); int campusId; //Populating a DataTable from database. if (hiddenCampusToViewValue.Value.Equals(string.Empty)) campusId = Convert.ToInt32(selectCampusToView.Items[0].Value); else campusId = Convert.ToInt32(hiddenCampusToViewValue.Value); if (Convert.ToInt32(Session["User-RoleId"]) == 3) dt = reservationData.DataTableReservation(campusId); else dt = reservationData.DataTableUserReservation(Session["User-UserName"].ToString()); } //Building an HTML string. StringBuilder html = new StringBuilder(); //Building the Header row. html.Append("<tbody>"); html.Append("<th>"); html.Append("Id"); html.Append("</th>"); html.Append("<th>"); html.Append("Space"); html.Append("</th>"); html.Append("<th>"); html.Append("Parking"); html.Append("</th>"); html.Append("<th>"); html.Append("Campus"); html.Append("</th>"); html.Append("<th>"); html.Append("User"); html.Append("</th>"); html.Append("<th>"); html.Append("Vehicle Plate"); html.Append("</th>"); html.Append("<th>"); html.Append("Initial Hour"); html.Append("</th>"); html.Append("<th>"); html.Append("Final Hour"); html.Append("</th>"); /*foreach (DataColumn column in dt.Columns) { html.Append("<th>"); html.Append(column.ColumnName); html.Append("</th>"); }*/ html.Append("</tr>"); //Building the Data rows. foreach (DataRow row in dt.Rows) { html.Append("<tr class='desmarcado'>"); foreach (DataColumn column in dt.Columns) { html.Append("<td onclick='getValue(this.parentNode)' style='cursor:pointer'>"); html.Append(row[column.ColumnName]); html.Append("</td>"); } html.Append("<td>"); html.Append("<button onclick='setValues(this.parentNode.parentNode)' type='button'>Edit</button>"); html.Append("</td>"); html.Append("<td>"); html.Append("<button onclick='deleteRole()' type='button'>Delete</button>"); html.Append("</td>"); html.Append("</tr>"); } html.Append("</tbody>"); //Append the HTML string to Placeholder. placeHolderTableReservations.Controls.Clear(); placeHolderTableReservations.Controls.Add(new Literal { Text = html.ToString() }); }
protected void FillTable() { DataTable dt = new DataTable(); if (selectCampusToView.Items.Count > 0) { ReservationData reservationData = new ReservationData(); int campusId; //Populating a DataTable from database. if (hiddenCampusToViewValue.Value.Equals(string.Empty)) { campusId = Convert.ToInt32(selectCampusToView.Items[0].Value); } else { campusId = Convert.ToInt32(hiddenCampusToViewValue.Value); } if (Convert.ToInt32(Session["User-RoleId"]) == 3) { dt = reservationData.DataTableReservation(campusId); } else { dt = reservationData.DataTableUserReservation(Session["User-UserName"].ToString()); } } //Building an HTML string. StringBuilder html = new StringBuilder(); //Building the Header row. html.Append("<tbody>"); html.Append("<th>"); html.Append("Id"); html.Append("</th>"); html.Append("<th>"); html.Append("Space"); html.Append("</th>"); html.Append("<th>"); html.Append("Parking"); html.Append("</th>"); html.Append("<th>"); html.Append("Campus"); html.Append("</th>"); html.Append("<th>"); html.Append("User"); html.Append("</th>"); html.Append("<th>"); html.Append("Vehicle Plate"); html.Append("</th>"); html.Append("<th>"); html.Append("Initial Hour"); html.Append("</th>"); html.Append("<th>"); html.Append("Final Hour"); html.Append("</th>"); /*foreach (DataColumn column in dt.Columns) * { * html.Append("<th>"); * html.Append(column.ColumnName); * html.Append("</th>"); * }*/ html.Append("</tr>"); //Building the Data rows. foreach (DataRow row in dt.Rows) { html.Append("<tr class='desmarcado'>"); foreach (DataColumn column in dt.Columns) { html.Append("<td onclick='getValue(this.parentNode)' style='cursor:pointer'>"); html.Append(row[column.ColumnName]); html.Append("</td>"); } html.Append("<td>"); html.Append("<button onclick='setValues(this.parentNode.parentNode)' type='button'>Edit</button>"); html.Append("</td>"); html.Append("<td>"); html.Append("<button onclick='deleteRole()' type='button'>Delete</button>"); html.Append("</td>"); html.Append("</tr>"); } html.Append("</tbody>"); //Append the HTML string to Placeholder. placeHolderTableReservations.Controls.Clear(); placeHolderTableReservations.Controls.Add(new Literal { Text = html.ToString() }); }