Add DropdownList to DataGrid at Runtime

J

James

I have a DataSet, which I'm manipulating and using to create a DataTable at
runtime. I'm generating all of the Columns and Rows and it binds just fine.
The problem I'm having is I need to create a new *row* on this datatable and
add a row full of DropDownLists at the end (one per cell, per column).

Basically:

Col1 Col2 Col3
data data data
data data data
DDL DDL DDL <---- Need to add these

How can I accomplish this? I'm not that concerned about event handlers, I
just can't figure out what the next logical step is:

Dim dt as DataTable
' misc code here
Dim dr as DataRow

dr = dt.NewRow()
????????

Thanks for any help you can offer.
 
G

Guest

I am not exactly sure what you are asking, but I think what you are trying to
do isn't done the way you are asking to do it.

See if this is what you are trying to do:
Use the "ItemDataBound" of the datagrid to place the ddl's in it.
I would recommend placing them in the footer:
If e.Item.ItemType = ListItemType.Footer Then
e.Item.Cells(0).Controls.Add(ddl0)
e.Item.Cells(1).Controls.Add(ddl1)
'etc...
End If
 
J

James

Yeah, I'm a moron...that's exactly what I ended up doing. Thank you. Not
sure why that slipped my mind. Thanks again...works perfectly.
 

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,772
Messages
2,569,593
Members
45,113
Latest member
Vinay KumarNevatia
Top