|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
looking for a special kind of table controlI'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 Hi Stephan,
I'd use a GridView with Tem\plateFields or your own custom fields. Check out MSDN for a pointer: http://msdn.microsoft.com/msdnmag/issues/05/12/CuttingEdge/ http://msdn.microsoft.com/msdnmag/issues/06/01/CuttingEdge/default.aspx I think this will be a big help for your problem. Grtz, Wouter van Vugt Trainer - Info Support http://blogs.infosupport.com/wouterv 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 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 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
new menu control is very slow
Control-level security Paging and Filtering in Gridview (.NET 2.0) Highlight row in a gridview after formview insert Question on Submit all fields on a tabstrip that is using multipage PublicKeyToken, GAC registering, and multiple developers?? ASP.Net 2 Two Way Binding and DateTime Format Problem XML Editor The mystery of passing form values Refreash DesignTime control. |
|||||||||||||||||||||||