Problems with dynamic template columns in a data grid

G

Guest

I've created several columns at run time and added these to my datagrid using
the following:

Select Case templateType
Case ListItemType.Header
lc = New Literal
lc.Text = "<B>" & columnName & "</B>"
container.Controls.Add(lc)
Case ListItemType.Item
myLabel = New Label
myLabel.ID = "lbl" & columnName
container.Controls.Add(myLabel)

AddHandler myLabel.DataBinding, AddressOf myLabel_DataBinding

Case ListItemType.EditItem
myTextBox = New TextBox
myTextBox.ID = "txt" & columnName & "Edit"
container.Controls.Add(myTextBox)
AddHandler myTextBox.DataBinding, AddressOf
myTextBox_DataBinding
Case ListItemType.Footer
myTextBox = New TextBox
myTextBox.ID = "txt" & columnName
container.Controls.Add(myTextBox)
End Select

When I bind to the grid it displays the data perfectly.

However, I cannot get data out of the grid. For example, I know I have a
column called Line Nbr which contains an EditItem text box called
txtLineNbrEdit. When I change the value I cannot read it.

If I do e.item.cells(0) I get no value.

If I do e.item.cells(0).FindControl("txtLineNbrEdit") it finds nothing.

I cannot get data out of the footer either.

I've tried everything I can think of but to no avail. Can anyone help?

Thanks
Simon
 
Joined
Jul 12, 2007
Messages
2
Reaction score
0
Problem with dynamic Template columns

i have same problem. when updating the column value. i am unable to find control. actually it discards dynamically added columns. any solution.

Regards,
Muhammad Rizwan Javed
Software Engineer.
MechTechnologies, Lahore, Pakistan
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top