Dynamic controls in DataGrid not retaining values

  • Thread starter Elliot M. Rodriguez
  • Start date
E

Elliot M. Rodriguez

I am not sure how to implement this.

I have a DataGrid which is bound to a DataSet that the user creates by
adding items from a dropdown box on my page. When the dropdownlist item is
selected, a new DataRow is created, and in my ItemCreated event I add a
DropdownList and a TextBox object in 2 separate columns of the grid.

The idea is to retrieve the values specified from those 2 controls and
update my DataSet with the values the user enters.

My problem lies in trying to access these controls. It seems they dont keep
their viewstate, and I think they are being recreated brand new on each
postback. Specifying the cell and the control's ordinal number in a
DataGridItem object throws an error (Index out of bounds).

So my question is - how can I get those values from the columns and complete
my processing once they submit the form?

Thanks in advance to all who can help.
 
E

Elliot M. Rodriguez

ok, I think I figured it out, but an error that I am working around needs
clarification.

This line:
txtPrice.Text = e.Item.DataItem("RetailPrice")

when Option Strict is turned ON, throws a precompiler error.

How can I implement what I want to do while still usign Option Strict?
 
D

DesignerX

Looks like you maybe trying to put a numeric value into a string container.

try:

txtPrice.Text = CStr(e.Item.DataItem("RetailPrice"))

or

txtPrice.Text = e.Item.DataItem("RetailPrice").ToString
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top