Ejemplo n.º 1
0
        protected void FillTable()
        {
            VehicleData vehicleData = new VehicleData();
            //Populating a DataTable from database.
            DataTable dt = vehicleData.DataTableUserVehicle(vehicleData.SendVehicleList(vehicleData.GetUserVehicle(Session["User-UserName"].ToString())));

            //Building an HTML string.
            StringBuilder html = new StringBuilder();

            //Building the Header row.
            html.Append("<tbody>");
            html.Append("<tr>");
            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.
            placeHolderTableVehicle.Controls.Clear();
            placeHolderTableVehicle.Controls.Add(new Literal { Text = html.ToString() });
        }
Ejemplo n.º 2
0
 protected void FillSelectVehicle()
 {
     //Fill select my cars
     VehicleData vehicleData = new VehicleData();
     DataTable dataTableVehicleOfUser = vehicleData.DataTableUserVehicle(vehicleData.SendVehicleList(vehicleData.GetUserVehicle(Session["User-UserName"].ToString())));
     selectVehicle.DataSource = dataTableVehicleOfUser;
     selectVehicle.DataValueField = "VehiclePlate";
     selectVehicle.DataTextField = "VehiclePlate";
     selectVehicle.DataBind();
 }