Insert multiple values(multiple columns) based on single dropdown list selection.

What I would like to accomplish:

 

I have a dropdown list that is an entityref(populated by values from PK in separate table).

When user makes selection in dropdown list, then clicks “Insert”, I would like the selected value to be inserted into the applicable FK column, but also would like to have a value equal to the integer selected, multiplied by 50, inserted into another column of the same table.

Example with user selecting “2” in the dropdown list, inserting into Table b:
table a: Column: Numbers(PK)

(1, 2, 4, 8)

Table b: Processors(FK)

Inserted: “2”
Table b: Factor

Inserted: “100”  (2*50)

 

I know how to “hide” the ‘Factor’ column from the user on the ‘Insert’ form, via my MetaData.cs file, but am unsure of how I would/could get this additional calculated value added to the insert.

 

0
gstadter
1/8/2009 2:38:15 PM
asp.net.dynamic-data 1365 articles. 0 followers. Follow

5 Replies
4203 Views

Similar Articles

[PageSpeed] 25

gstadter:
I would like the selected value to be inserted into the applicable FK column, but also would like to have a value equal to the integer selected

This is what happen by default

gstadter:
but also would like to have a value equal to the integer selected, multiplied by 50, inserted into another column of the same table.

This could be done easily with some business logic but first I need to know which framework you are using for you datamodel Linq to SQL or Entity Framework are the business logic is implmented differently for each Big Smile


Steve Big Smile

Seeking the elegant solution.
[Oh! If olny I colud tpye!]
c# Bits blog
Oh, and don't forget to mark as answer any posts that help you Big Smile
0
sjnaughton
1/8/2009 5:01:48 PM

Using Linq to SQL.

Could this entirely be done in the MetaData?  or would I ned to manipulate the datasource in a custom page template as well?

Idealy, the Factor integer value would get updated whenever the record is updated(same FK dropdown list) as well (not just apply to inserts).

0
gstadter
1/8/2009 5:38:43 PM

should I be looking into using OnProcIDChanging(int? value)  ?

0
gstadter
1/8/2009 5:47:38 PM

Sorry for the delay here's a sample (and yes entirly done in the partials metadata file Big Smile

public partial class NWDataContext
{
    partial void InsertOrder_Detail(Order_Detail instance)
    {
        int multiplier = 50;
        instance.Discount = instance.ProductID * multiplier;
        this.ExecuteDynamicInsert(instance);
    }
    partial void UpdateOrder_Detail(Order_Detail instance)
    {
        int multiplier = 50;
        instance.Discount = instance.ProductID * multiplier;
        this.ExecuteDynamicUpdate(instance);
    }
}
This of course is a nonsensical calculation but just submit you fields appropriatly. Big Smile
Steve Big Smile

Seeking the elegant solution.
[Oh! If olny I colud tpye!]
c# Bits blog
Oh, and don't forget to mark as answer any posts that help you Big Smile
0
sjnaughton
1/8/2009 6:04:31 PM

"sorry for the delay" ??? Really?
Your response time, helping myself and others on these forums, is absolutely amazing.

The code you provided worked perfectly.

Appreciating the power of DynamicData more and more each day,
Gary Stadter 

 

0
gstadter
1/8/2009 6:37:07 PM
Reply:

Similar Artilces:

How to select multiple data from multiple data grids and insert then into another data base??
How to select multiple data from multiple data grids and insert then into another data base??There are check boxes to select data from the data grids.plz help me out!!!! Hi:   I think you can simply loop through all rows of your DataGrids, check whether the CheckBox is checked and decide whether to insert data.   Reference: Selecting multiple checkboxes in a DataGrid control http://www.codeproject.com/aspnet/datagridCheckboxes.asp DataGrid CheckBox Select Multiple Rows Column http://www.codeproject.com/aspnet/dgcheckboxcolumn.asp   Please post your current code a...

How to insert multiple values in a single column
I need to display output as shown below. In Col1, Col2 and Col3 I want to insert values from subqueries. But do not want to use sub-reports... is there any alternative to subqueries. In Col1, Col2 and Col3 there can be any number of values. Company Bank Col1 Col2 Col3 AstroTech ICICI 1 2 3 5 3 4 MindTree HDFC   5 4 8          Pardeep Bogra (MCA, MCAD)Systems Develper  why don't you want to use a sub-report? It takes very long time, because i have 17 colu...

Multiple values for multiple items insert using c#.net
Hello, I have an application that allows the user to insert multiple values all related to the same item that reside in multiple tables. example base information, style general details, parts of a style etc. a single table binds them all together using foreignkeyid's. This is kind of a slow process, because they might have to create a set of styles in different colors etc on the same day. say 15 items which are different only in color. Now, I' m having to design a form which will let them insert all 15 items at once.  I dont know how to show you the lay out I have?? My idea abo...

Matching each value out of multiple values to single column value
 Hi,  @whoposted in stored procedure holds value "agent  builder owner"  ( please note the space in between) My column  POSTED_BY  always holds one and only one value out of above 3.Example:       POSTED_BY  owneragent          etc... If  All / any of the value hold by  @whoposted matches with value of POSTED_BY column, i want to show that row in gridview.( Also, please note, str may hold different values depending on user selection. For example, it may ...

Populate dropdown list based on selected value in another dropdown list
I have a datagrid (grdCar) that contains two dropdown listboxes (ddlCarManf and ddlCar). When the user clicks the "Edit" link and places the grid into edit mode, they select a value in ddlCarManf. Based on the selected value in ddlCarManf, I need to then populate ddlCar with a list of cars for which the selected manufacturer makes (I'm using ddlCarManf.SelectedValue to query the database).  I bind my datagrid in the page_load event as: If Not Page.IsPostBack Then    BindGrid() End If Here is my control (ddlCarManf) as is appears within grdCar in ...

Hiding the gridview columns based on multiple selection values of a listbox
Hallo there, I am having a problem on hiding gridview columns based on values selected on a listbox. For example I have a gridview, a listbox and a button. The gridview consists of 3 columns: userID, FirstName and LastName. So Does the listbox contains 3 items: userID, FirstName, and lastname. What I need is, if user clicks on FIRSTNAME in the listbox and click on the button, the FIRSTNAME column can be hidden. I have tried to use gridview.columns(i).visible but this is not what I want 'coz the values of i are determined of the order of listbox. Thus, it makes column with the order o...

selecting multiple values in a list box using vb.net code
Hi, I have a list box with certain values. The SelectionMode property of List box is set to Multiple. I want to select multiple items based on the values of the items in the Listbox using the vb.net code. Can any one please help.Thanks eg: for i = 0 to listbox.items.count - 1 if listbox.items(i).selected then Response.Write("Selected") else Response.Write("Selection Needed") end if next refer links: http://www.411asp.net/func/content?tree=411asp/tutorial/specific/web/userinte/webcontr...

Dynamic Dropdown lists
Hi,  I have a fixed dropdown list and a dynamic drop down list which changes according to the value selected in the fixed list. I have a problem where i'm trying to set the value of these lists according to a parameter passed through the url and finding the appropriate record. The problem occurs if i try to change the fixed list as it says i can't have multiple items selected.  Can anyone help, thanks.  Gemma what i can understand is, When you change the fixed list, the page is submitted i.e. postback. In this case perhaps the value fields for dynamic or fixed dropdowns a...

Cascading Dropdown List
Hi, First post so hello and need some help with an issue I have been dealing with.  I have an intranet page I created in ASP.NET using C# .NET 3.5 with a few Ajax Extenders including 3 Cascading Dropdown Lists. Now I have used the Cascading dropdown lists for my own purposes i.e they do not actually cascade their results to another dropdown list, the reason I did this was due to the having a User Control that contains an update panel and other bits i.e I didn't want the control/page posting page (something that happens when you click on a regular dropdown list). Everything is wor...

how to auto insert the value of multiple records into dropdownlist base on user selection in c#
Hi, I have one gridview with column emp#, status.   'status' column is a dropdownlist with 3 types of status for user to select, that is 'approve,disapprove,onhold'.  By default system will set status as 'onhold'.  Example of gridview data as below: Emp#        Status(dropdownlist)         001           onhold            002    &nb...

How do you pre-select values in a multiple selection list box
Let's say I have a list box like so, this is already rendered: <select name="names" size="3" multiple="multiple" id="names1" > <option value="0">John</option> <option value="1">Mike</option> <option selected="2">Bill</option> </select> how could I pre-selecte two names on load, if I say names1.selectedvalue = "1" it pre-selects Mike cool but if I say names1.selectedvalue = "1,2" then I get an exception. Is there a way ...

SQL,Make Multiple values for multiple columns into one column separated by comma
Hi, I'm getting the result as this Name       Class       Subject------------------------------------------Anju         10             MathsAnju         10             Physics How to write the query to get the result like this Name       Class       Subjects------------...

Displaying single column of data across multiple columns..
Hi all... Okies my problem.... I have a dataset that has a single column, with 100 rows. I wan't to display this in a table with 4 columns with 25 rows in each column.. Does anyone know of a simple solution? Thank's in advance. Jeremy Baka Saru Hi, you can try the DataList with RepeatColumns property set to 4.  Alvin ChooiMicrosoft ASP.NET™ Enthusiast v1.1 / v2.0, Malaysia Blog : http://alvinzc.blogspot.com...

Displaying a single Data Window Column in multiple columns
I have a datawindow that is retrieving a single column. Using Powerbuilder 5.04, is there anyway to display this data in multiple columns sorted (alphabeticlly) vertically (eliminates n-up). Any help would be appreciated. Thanks Yehuda Newspaper columns? Yehuda wrote in message <3ACB5511.E9262E3C@yahoo.com>... >I have a datawindow that is retrieving a single column. Using >Powerbuilder 5.04, is there anyway to display this data in multiple >columns sorted (alphabeticlly) vertically (eliminates n-up). Any help >would be appreciated. >Thanks >Yehuda &...

Web resources about - Insert multiple values(multiple columns) based on single dropdown list selection. - asp.net.dynamic-data

Selection - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Cricket: ACT Comets selection trial unearths young talent pushing for Futures League spots
... Creek Molonglo fast bowler Joe Slater (3-31) also stood up, catching the attention of Comets senior coach Kyle Piper. "Each of the selection ...

Tim Bosma murder trial to start Monday with jury selection
The trial of two men accused in the death of Tim Bosma is set to begin Monday with jury selection, which is expected to last up to two weeks. ...

Jeff Long no longer chair of College Football Playoff Selection Committee
Arkansas athletic director Jeff Long's tenure as chairman of the College Football Playoff Selection Committee will end after two seasons.

Jury selection set in fatal 2014 Bourbon Street gunfight - Fox News
A trial is scheduled to begin in New Orleans for the only person arrested following a 2014 gunfight on Bourbon Street that left a bystander dead ...

Jury Selection Starts in Prison Contraband Drone Case
Jury selection is underway for the trial of a Maryland man accused of planning to use a drone to fly drugs, tobacco and pornography into a maximum-security ...

Rashida Jones Sings & Stars In Boss Selection's 'Flip & Rewind' Music Video
... executive producer Jo Miller of Full Frontal . Rashida recently teamed up with her nephew Sunny Levine for his brand new project Boss Selection ...

Today’s selection of articles from Kotaku’s reader-run community: How I Learned to Stop Worrying and
Today’s selection of articles from Kotaku ’s reader-run community: How I Learned to Stop Worrying and Love Warcraft Lore - Orgrim Doomhammer ...

2015 National Film Registry Selections
The Library of Congress named this year’s National Film Registry selections today . As usual, it combined some big-budget movies people love ...

DDCA Official Asked For Sexual Favours in Return of Selection: Arvind Kejriwal
Home Top news Nation World States Telangana Andhra Pradesh Karnataka Kerala Tamil Nadu Odisha Cities Bengaluru Chennai Kochi Thiruvananthapuram ...

Resources last updated: 1/20/2016 5:19:59 PM