Dynamic controls in DataGrid not retaining values

  • Thread starter Thread starter Elliot M. Rodriguez
  • Start date 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.
 
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?
 
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
 
Back
Top