One form to update different SQL tables based upon form selection

Hello,

My company Intranet has a form that agents can use to post their comments about the company to upper management, but our customer service department would like to modify the form so that the agent has to pick from a comment type.

The dropdown options on the form will be as follows:

Compliments
Complaints
General Comments
Suggestions

Each dropdown option has a designated table in a SQL DB.
Using postback on the same page, I need to change which fields of the form are visible based upon which dropdown selection the user chooses, and I need the fields to then be inserted into the table that corresponds with the dropdown selection item.

For example: If the Compliments dropdown selection is picked, I need a text box to show for the user's location, the name of the customer, account number, and the message box. Once the submit button is clicked, the characters in these boxes need to be inserted into the Compliments table using its data adapter.

However, if the user selects Suggestions, the name of the customer and the account number should not be visible, since these fields do not exist and when the submit button is pressed, the Suggestions table should be updated.

If you need more information, I will provide whatever is needed.

As always, thanks for everyone's assistance.

Chris


Web Developer
SCFoster
0
ccountey
4/16/2008 5:49:30 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

3 Replies
329 Views

Similar Articles

[PageSpeed] 3

There are several ways to do this.

I'll describe a simple way. 

You might consider using a multi-view.  A multi-view can have several "views" (hence the name), each of which can have different sets of controls in it.

Only one set of controls is visible at a time.

Basically, the drop-down list of choices would also set which view in the multi-view would be visible.  Then, you just build a separate view per drop-down choice.  In effect, you have 4 different (but simple) pages on the same page, only one of which is used at any given point in time.

 

0
david
4/17/2008 5:37:54 AM

As said in the before post,  by using multiviews u can achieve this functionality. and it will be clear understanding to the others.

If u don;t wnat to replicate the controls, u can achieve it by changing the visibilities of the controls, when dropdownlist selected index is changed. you can change these visibilities  either in javascript or in server side event.

      Eg:

dropdownlist1.attributes.add("onchange","javascript:return ChangeVisibility()");

function changeVisibility()

{

if(document.getElementById(dropdownlist1).selectedindex  == 0)

{

document.getElementById(
"<%=trPercentage.ClientID%>").style.display = "none"; // liek this by using none or block u can make that control as visible or invisible.

}

if(document.getElementById(dropdownlist1).selectedindex  == 1)

{

document.getElementById(
"<%=trPercentage.ClientID%>").style.display = "none";  // by using none or block u can make that control as visible  or invisible.

}

if(document.getElementById(dropdownlist1).selectedindex  == 2)

{

document.getElementById(
"<%=trPercentage.ClientID%>").style.display = "none"; // by using none or block u can make that control as visible or invisible.

}

if(document.getElementById(dropdownlist1).selectedindex  == 3)

{

document.getElementById(
"<%=trPercentage.ClientID%>").style.display = "none"; // by using none or block u can make that control as visible  or invisible.

}

 

 

}

 

 


Give a man a fish and you feed him for a day. Teach a man to fish and you feed him forever.
0
ramireddyindia
4/17/2008 5:52:58 AM

Thanks for your response. I'm not familiar with the Multiview function, but this is a step in the right direction.

Chris


Web Developer
SCFoster
0
ccountey
4/17/2008 2:08:16 PM
Reply:

Similar Artilces:

Wanting to take info from one SQL table and update to a seperate SQL table
Anyone have an idea of how I can take information from one table and edit it and insert into another SQL table.  I am using stored procedures and would like to continue to do so. Here is a copy of what I have so far:   <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="mp_Customers" SelectCommandType="StoredProcedure"></asp:SqlDataSource> </div> <h2><strong><font color="#C00000">Please enter a valid account number:</font></strong><...

I imported a SQL Table into SQL DataBase, But I can not update this table even with SQL Server management Studio
I imported a SQL Table into SQL DataBase, But I can not update this table even with SQL Server management Studio When I change any data on mentioned table above, Red exclamation sign appears left of the record . How can I correct this problem?  Thanks. Try running the UPDATE via Query Analyzer...and see if you get an error.***********************Dinakar NethiLife is short. Enjoy it.***********************...

Unable to update SQL Table from a Web Form
I have a Table which stores data from two different databases. To update it I made a Web Form that opens a single record where you can edit the data (using TextBox). Then there is an Update Button, which is supoused to Update that record in the SQL Database. However, for some reason it does not work. I get no error and every thing seems to work fine, but the data is not updated. When running the same UPDATE statment in the SQL Query Analyzer everything works just fine. Here is the code for the button click (For test purpose I've set a spesific record to update the Task cell to "Tes...

Continuation of saving form data to sql table and having a link open up the form with record just saved
Hello,   I am new to .net and posted earlier on this subject which has many parts.  In this post I just want to know when they fill out the form and hit submit to email the superviosr with link that points to form just filled out , do I save the form fields to the sql with table adapter that has querires and does this go in the submit button which is send or do I put this in a class. If i put it in the class it does not know the objects on the form. This may sound stupid but am having a hard time finding the best way to do  this.   Thanks for any help, SB H...

Submit Form to insert data into SQL and display with a gridview (edit as well) below how do i insert data into sql table?
I have an asp.net page that has a simple form where a user can submit customers information. Below that I have a gridview which displays customer information submited by the user who is logged in. I have the gridview displaying, sorting and updating as I want however I can't figure out how to bind a button click to insert data into the customer table and then have it refresh the gridview when they submit. Here is the basic code; (I am using AJAX for a calendar when a user wants to edit an appointment date) &lt;div class="leftBar"&gt; <div align=center&...

Bulk update of items in an MS SQL data table, based upon current value.
I have a "products" table in my MS SQL 2005 database which includes the fields "GroupID" and "Price". (Approx 9000 items in products). I wsh to update the price of all items Where GroupID=4 to a value that is current value + a constant (Price+2.00). (Approx 3000 items). I am lost as to the SQL script that would do that - though it seems such a simple task? Any help and pointers would be truly appreciated. You basically have the SQL query already in your text. Just SQL:ify it a bit ;-) UPDATE products SET Price = Price + 2 WHERE GroupID = 4  If this p...

How to write SQL to form &quot;New Table&quot; from Job Revence and Job Cost using SQL statement ? thx
Edited by SomeNewKid. Please post code between <code> and </code> tags. // Pls copy the following HTML after that you generate the HTML page. Then you will know what I mean. I need to form "New Table" from Job Revence and Job Cost using SQL statement? thx -----------The following code----------------- <META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=big5"> <html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/...

tell m what i have to do,to traverse through records one after another-when i press next button on a form(using sql server,vb.net)
where "next_record" is declared has global variable.its displayin "first record" on the form.can anyone tell m what i have to do traverse through records one after another-when i press next button..plz reply m its very urgent...      Private Sub nxt_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nxt_btn.Click nextbtn() End Sub Public Function nextbtn() As StringDim str As String = "select * from table1" 'try to write "select distinct * from table1"Dim con As String = ConfigurationSetting...

can someone one give me difference between web form and mobile web form and which or where or when i'm using the forms?
thanks Marc Hi Marc, Based on my understanding, you want to know the differences between the ASP.NET web application and ASP.NET mobile web application. If I have misunderstood you, please feel free to let me know. The ASP.NET forms are used to develop the ASP.NET pages for desktop browsers and The ASP.NET mobile forms are used to develop the ASP.NET pages for mobile device browsers. When we create the ASP.NET mobile web forms pages, we can use nearly all the features of ASP.NET. But there are a couple of compatibility issues: Error Handling and Reporting. Tracing. Using Redi...

Submitting Web forms fields to sql database by clicking on SUBMIT FORM and sending the form fields to email box
I have a created or designed a form to be stored in a SQL database table and at the same time when a user clicks on SUBMIT button the form fields will automatically goto the visitor email address immediately. Also i have created a database with tables for each of this forms Pls help i have over 10 forms designed but the problem of submitting them to the table database and the user email address is the challenge now.... You ned to familiarise yourself with the basics of database access in ASP.NET.  There are free tutuorials here: http://quickstarts.asp.net/QuickStartv20/aspnet/doc/da...

I submit a form and insert data to the sql, then I want to show the thank you message, not show the form. how can I switch the form to the thank you message.
Here is my code: if (Page.IsPostBack) // form submitted {SqlConnection sc = null; SqlCommand command = null; try {sc = new SqlConnection(ConfigurationManager.ConnectionStrings["SiteSource"].ConnectionString); sc.Open();String strSQL = String.Format(@"INSERT INTO Contactus (ContactusEmail,ContactusFirstName,ContactusLastName, ContactusPhone, ContactusComments, ContactusDate) VALUES ( '{0}', '{1}', '{2}', '{3}', '{4}', '{5}')", EmailBox.Text, FirstNameBox.Text, LastNameBox.Text, PhoneBox.Text, CommentsTextBox.Text,...

More than one table for a form updateable
Is there a way to make more than one table updateable in a form? Thanks,Sheri ...

Problems with SQL and update from form
I am trying to upgrade my site from Microsoft Access to SQL and it runs fine except when I try do the update from the webform. BElow is my code. If someone can see why it is happening that would be great:  The error I get is: Line 1: Incorrect syntax near 'nvarchar'. <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="HIGHWAY" title="Untitled Page" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"...

SQL/Forms Based Authentication
Hi, I'm fairly new to ASP.Net security. Im trying to create a standard ASP.Net application that posts to itself, and validates ie. A user/pw from a database. I prefer to not use a stored procedure for calling that information if possible.. Can someone give me an example of this and can I do role based authentication this way as well? ie. DB field called Role (or in a relational db method). I'm very familiar with standard ASP, and just starting to migrate all my asp applications to .net entirely. Just tryin to understand the DB side of things still. (some is familiar, but new ...

Web resources about - One form to update different SQL tables based upon form selection - asp.net.sql-datasource

Sarah Palin endorses Donald Trump
The tenor of her announcement, and of the American right in general, is perfectly summed up by this Vine video: (more…)

BlueVine Raises $40 Million To Help Small Businesses With Cash Flow
Another big bet on “FinTech,” Palo-Alto based BlueVine has raised $40 million to provide credit lines for small businesses. The round is led ...

Oscars 2016: George Clooney and Lupita Nyong'o add to criticism
BBC News Oscars 2016: George Clooney and Lupita Nyong'o add to criticism BBC News Oscar-winning actor George Clooney has accused the Academy ...

Jamie Foxx praised for saving man from burning truck
BBC News Jamie Foxx praised for saving man from burning truck BBC News Jamie Foxx has been praised for saving a man who was trapped in a burning ...

The Most Evil Heroes of All Time Have Arrived in the ‘Suicide Squad’ Trailer: WATCH
Last night the trailer for David Ayer’s highly-anticipated Suicide Squad adaptation of the DC Comics series hit the streets. It features the ...

Jar Jar Binks meets a violent end in excellent Star Wars Episode 7.5 fan comic
Is the two-year wait for the next numbered Star Wars movie too long for you? Do you need closure on the stories of Rey, Finn, Poe Dameron and ...

Linda Ronstadt, whose backing band was the hub for the Eagles, remembers Glenn Frey
Los Angeles Times Linda Ronstadt, whose backing band was the hub for the Eagles, remembers Glenn Frey Los Angeles Times No one ever suggested ...

Univision Gets Serious About Funny Business, Announces They Are Buying The Onion
The idea of Spanish language media giant Univision buying The Onion , a website devoted to comedy might sound like joke, maybe even the premise ...

Islamic State says two assailants in Paris attacks are from Iraq
The Islamic State group published pictures of nine militants it says carried out Nov. 13 attacks that killed 130 people in Paris including two, ...

Microsoft plans to donate $1B in cloud services to nonprofits, researchers
Microsoft plans to donate $1 billion in cloud services over three years to nongovernmental organizations and researchers in a bid to provide ...

Resources last updated: 1/20/2016 1:26:10 PM