473,327 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Dynamic controls in DataGrid not retaining values

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.
Nov 17 '05 #1
2 1592
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?

"Elliot M. Rodriguez" <elliotmrodriguezatnospamhotmail.com> wrote in message
news:OI**************@TK2MSFTNGP12.phx.gbl...
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.

Nov 17 '05 #2
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


"Elliot M. Rodriguez" <elliotmrodriguezatnospamhotmail.com> wrote in message
news:uJ**************@TK2MSFTNGP09.phx.gbl...
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?

"Elliot M. Rodriguez" <elliotmrodriguezatnospamhotmail.com> wrote in message news:OI**************@TK2MSFTNGP12.phx.gbl...
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.


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jo | last post by:
Hi, I've tried the suggested solution but I'm still getting the same error. It seems that once the page postback is envoked the checkbox control is removed from the datagrid so all my changes...
0
by: JP011 | last post by:
Hello I have hit a major road block when it comes to building my dynamic datagrid. To make a long story short I need a dynamic datagrid because my connection string could change and I need the...
7
by: Bil Muh | last post by:
Esteemede Developers, I would like to Thank All of You in advance for your sincere guidances. I am developing a software using Visual C++ .NET Standard Edition with Windows Form (.NET)...
4
by: Tom Wisnowski | last post by:
Hello all, Here is a simple example of what I'm doing... Create a ASPX page Add a PlaceHolder(plch) and a Button(btn) to the page. In the code behind on Page_load add the following......
3
by: PABruceFan | last post by:
I am dynamically adding rows to an asp:table as a result of a database query. The row consists of a label, a textbox and three checkboxes in that order: LABEL TEXTBOX CHECKBOX1 CHECKBOX3 ...
0
by: Sue | last post by:
I'm missing something very simple here, and I need an answer fairly quick if possible. I'm behind on this project now because of this... Code examples below question... I have a datagrid (DG)...
1
by: Elliot Rodriguez | last post by:
I have a dropdown list that defines the number of textboxes that appear within a particular panel. The boxes are created when the dropdownlist's SelectedIndexChanged event fires on postback. ...
0
by: cindy | last post by:
I have a dynamic datagrid. I have custom classes for the controls public class CreateEditItemTemplateDDL : ITemplate { DataTable dtBind; string strddlName; string strSelectedID; string...
3
by: =?Utf-8?B?ZGVuIDIwMDU=?= | last post by:
Hi, Trouble in retaining values of dropdownlist, textboxes, and other controls when dropdownlist selectedindexchanged event is triggered, the controls are inside a user control and this user...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.