looking for a special kind of table control

S

Stephan Steiner

Hi

I'm wondering what you'd suggest on how to implement the following scenario:

A table based date entry/editing having 5 columns. One is an SQL bound
dropdown, another one a simple text item dropdown, the third one a numerical
entry box with a limited number range, the 4th is a read only textfield
whose content is recalculated according to changes made in the first and
third column and each time the first or third column is being changed
(performing an additional query on the SQL Datasource and then making a
quick calculation), and finally a free form text entry field (just plain
text, no formatting).

I need to have the functionality to delete an existing line, as well as
adding one, and an option to fill the table with some default values (by
default that's three entries with the same item selected in the first
dropdown, a different one in the second dropdown and an entry in the
numerical entry textbox). In the end, all entries need to end up in an SQL
DB (just a single table).

I'm currently considering two approaches. One based on basically writing the
table out programmatically. Clearly not a pretty solution. The other would
be starting out with a GridView, but I see a lot of work coming may way as
well. If you suggest that option, are there any useful samples out there to
give me a head start (preferably for ASP.NET 2.0).

Regards
Stephan
 
S

Stephan Steiner

Thanks for those links. I had already read the first one, and while I
couldn't directly apply it, it's still interesting.

I do have a followup. My PK for the table in question contains one non
changing parameter I get from a session variable, and two values (displayed
in columns 1 & 2), which can be changed.

So, in my updatecommand, I need to put the values of column 1 & 2 prior to
the update, in addition to the new values after the update. I can get those
values when I begin to edit, store them as global variables, then catch the
update link being pressed and do the update from within my own code. I'm
just wondering if there's perhaps a more automated way?

Regards
Stephan
 
W

Wouter van Vugt

Hi Stephan,

if you have PrimaryKey values which shouldn't be updatable, you can add
the names of these
fields to the DataKeyNames property on your GridView. They'll be
available for use in the update command
on your DataSourceControl.

Grtz, Wouter
 
S

Stephan Steiner

I'm already using DataKeyNames. The thing is, I have two of them
(corresponding to column 1 and 2), but they can be changed. The third one is
from the session, that one is immutable.

While using the DataKeyNames works just fine, the command must look
something like this "UPDATE table SET column1 = new_value_col1, column2 =
new_value_col2 WHERE column1 = old_value_col1 AND column2 = old_value_col2".

So I can't use DataKeyNames[0] for new_value_col1 and old_value1 and the
respective for the other key.

The only way I know how to get both values is to store them once editing
starts.

Regards
Stephan
 

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

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top