Add controls in datatable

A

Andre

Hi,

I want to add a Textbox in my datatable before binding my datagrid with
it. But i can't find a way to do it.

Did someone know what i'm doing wrong ?

- If i write <asp:textbox....> the column is empty.
- If i create my textbox on the onitemdatabind event, my textbox is on
another line of the datagrid.
- if i try to make it this way my colum is empty :
Dim txtbox As New TextBox
txtbox.Visible = True
txtbox.Attributes.Add("runat", "server")
txtbox.ID = "opt"
txtbox.EnableViewState = True
dr(1) = txtbox

Thank you, and i paste a copy of my code below.


Dim dt As DataTable = New DataTable
Dim dr As DataRow
Dim dv As DataView

dt.Columns.Add(New DataColumn("Service", GetType(String)))
dt.Columns.Add(New DataColumn("Option", GetType(TextBox)))
dt.Columns.Add(New DataColumn("Install", GetType(Decimal)))
dt.Columns.Add(New DataColumn("TypeA", GetType(String)))
dt.Columns.Add(New DataColumn("Servicen", GetType(String)))
dt.Columns.Add(New DataColumn("Month", GetType(Decimal)))

if my product number = 10 ......

dr = dt.NewRow
dr(0) = "Product 10"
dr(1) = *********** Create textbox here ************
dr(2) = Prix
dr(3) = myReader.GetString(3)
dr(4) = String1
dr(5) = myReader.GetValue(4)
dt.Rows.Add(dr)

dv = New DataView(dt)
DataGrid1.DataSource = dv
DataGrid1.DataBind()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top