---
title: "Dynamically creating HTML and asp elements from code behind"  
description: "Dynamically creating HTML and asp elements from code behind"  
author: "Anonymous User"  
published: 2014-12-05  
updated: 2014-12-05  
canonical: https://www.mindstick.com/forum/12748/dynamically-creating-html-and-asp-elements-from-code-behind  
category: "asp.net"  
tags: ["c#", "html5"]  
reading_time: 2 minutes  

---

# Dynamically creating HTML and asp elements from code behind

I am [filling](https://yourviews.mindstick.com/audio/1303/the-power-of-silence-what-happens-when-you-stop-filling-every-moment) a [DataTable](https://www.mindstick.com/blog/195/datatable-in-ado-dot-net) in the [code behind](https://www.mindstick.com/forum/2199/call-javascript-s-function-from-code-behind) my webpage and [trying](https://answers.mindstick.com/qa/93698/6-mistakes-couples-are-trying-to-save-money) to use it to create a "p" tag which has [text](https://www.mindstick.com/blog/301635/did-people-reinvent-texting-to-express-the-full-range-of-emotions) of the [service](https://www.mindstick.com/articles/105963/online-thesis-writing-service-for-college-kids-with-disabilities) [option](https://www.mindstick.com/forum/159391/jquery-get-selected-option-from-dropdown) followed by an ASPxCheckBox. [Problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) that I'm having is that I can't seem to get them within the same line, they are separated. Any assistance would be greatly.

## The code so far:

```
        Dim dtExample As New DataTable        dtExample.Columns.Add("ID")        dtExample.Columns.Add("Option")        dtExample.Columns.Add("Price", GetType(Decimal))        dtExample.Rows.Add({1, "Engine Flush", 99.95})        dtExample.Rows.Add({2, "Oil Check", 19.95})        dtExample.Rows.Add({3, "Pump Up Tires", 9.95})        dtExample.Rows.Add({4, "Air Conditioner", 69})        dtExample.Rows.Add({5, "Brake Fluid Checker", 49.95})          For Each row As DataRow In dtExample.Rows            Dim cb As New DevExpress.Web.ASPxEditors.ASPxCheckBox            Dim ParaElement As New HtmlGenericControl             ParaElement.InnerHtml = "<p class='serviceoption center' id='" & row("ID") & "'>" & row("Option") & "</p>"            cb.ID = row("ID")            cb.Checked = False            cb.Visible = True            cb.ClientInstanceName = row("ID")            serviceoptions.Controls.Add(ParaElement)            serviceoptions.Controls.Add(cb)        Next
```

## Replies

### Reply by David Miller

a P is a paragraph, if memory serves me right that will always be on a new line.

I suspect you want something like this but using css instead of the inline styles shown below

```
<div style="float:left;margin-right:10px;">Your Text</div><div style="float:left;clear:right;">Your Checkbox</div>
```

### Reply by Norman Reedus

Devexpress controls can be difficult to style in some cases. Rather than wrapping your checkboxes within a p tag, I would suggest setting the CssClass property of the AspxCheckboxto a CSS class containing your styling, and setting the descriptive text of the checkbox by using the Text property rather than a p tag.


---

Original Source: https://www.mindstick.com/forum/12748/dynamically-creating-html-and-asp-elements-from-code-behind

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
