I am currently have an asp.net web site through visual studio that contains three .aspx pages. Each .aspx page has simple label and text box fields in it. There is a button in each web aspx page also that redirects to the second and third page as well as a submit button at the end of the third page. Also behind the buttons there is an sql command/ query that Inserts the input from the textboxes into an sql database. I have one table in the database that I want input from all three pages. When I tried to do this the input from the first page correctly stayed in the first row. Then the input from the second page made its own second row and so on... I am also using a INSERT statement for each web aspx page. I have a picture below of what the database looks like... how can I get all the input into one row
With your current configuration you'll need an update statement instead of an insert statement on the subsequent pages.
You could also do something like session variables and just insert after you've collected all the information.
If you want to get it into one row, you need to do one INSERT statement and the rest should be UPDATE statements.
Each and every INSERT statement will create a new row in the database.
When trying to UPDATE a row, make sure you add something like WHERE ID = x, so you only update the one row.
Related
I want to build a web page using asp c# which has 4 Cells Labeled "MachineName (Label), Owner (Dropdownlist), Release(dropdownlist with default values of Yes/No), Comments (Textbox)".
Content of the table is loaded from SQLServerDB.
1. In each cell it shows records for one Machine.
2. Owner is dropdownlist, which consist names list from SQLTable (ADuser) of 500 users. But by default it show the current owner of this machine fetched from SQLServer Table (inventory) from which we are getting machine names.
3. Release is simple dropdownlist with default values "Yes/No".
4. Comments is just Textbox.
5. Update/Submit button to update the record column.
I am trying to put all these in simple line. Machine name is static which cannot be edited, Dropdown, Release and comments should be editable and finally with Submit/link button at the end of the Columns to update the particular record only.
I tried by creating Grid, but in grid we get DELETE/EDIT/UPDATE button options.
Tried by creating Placeholder and generating and filling data using htmlappend option. But this way, i am not able to add/bind dropdownlist dynamically.
Any help is appreciated.
I am working on asp.net web application.
I have to display data to the user in table format (it could be a table or gridview or something else ).
There is one column which has two signs plus and minus. I have to display data of n records, so there could be maximum n no. of rows. Rows will be created dynamically. Initally there will be only one row. User will fill details in first row and if he wants, When user clicks on plus sign, one row will be added below this row and if he clicks minus in a row that particular row will be deleted.
So I want this to be handled on client side not on server side and I dont want postback or page reload.
Is it possible by jquery, java script or ajax. Please suggest me how.
You can do this with a some AJAX, I prefer to use JQuery to streamline the process for me. When I do the same thing on my pages this is how I do it:
The page loads without the table.
The page (from the client) sends an AJAX request to the server for the table data.
The table data is returned and the table itself is built in javascript. This can be done by generating the table object or you can write the html yourself (that's how I do it).
I attach events to the two buttons, in your case a plus and a minus, that fires a javascript event.
The javascript event sends an AJAX request back to the server asking for a delete or new row.
The deleted row is either removed in javascript, or added in.
Now you can either request the data through AJAX and then build the table row yourself, or you can ask the server to send you the row pre formatted. Either way remember that these objects, the buttons and the table, will not be ASP.Net objects, will not be in Viewstate and will not persist through post backs so be prepared to rebuild this table each time you perform a post back.
I have a table called TableExplorer which contains other table's names and their respective column names.
For example: table Customer may have 5 columns but in TableExplorer I may mention only 2 column names out of 5.
User send me the table name in query string, my job is to find that table name whether it is present or not in TableExplorer which I mentioned initially. If the user mentioned table is present then I should bind that table to a gridview and that gridview should have functionality like edit, delete, update. Finally any operation like edit, delete or update made by user should reflect in the respective table as mentioned by the user.
Database used : SQL Server 2008 R2
Programming language : C#, ASP.NET
Thanks in advance for helping.
Are you using WebForms? I'm far from being a WebForms expert but this is what I'd do:
You create different pages with GridView control, one for each table that you might want to bind, eg. Customer table. You create the CRUD operation for this GridView, Insert, Update, Delete. You create parameters for all the columns that the user might need, some of them could be invisible.
The user goes to his selection page, he choses a table and a list of columns and press Submit his request. Whenever you receive the query string you do 2 things:
Identify what table your user is asking and load the right page, if available. Maybe you can load only the specific GridView control in a specific using Ajax. Or maybe you can simple load another page.
Get the list of columns that the user wants to see in his grid from the querystring. Before showing the grid to him you keep these columns visible and hide/remove from the gridview every other column. You must pass this parameter to your insert/update methods as well.
I think this is a good solution to start, assuming you don't have a list of hundreds of tables, I wouldn't try to create something completely dynamic.
I have a workout database where some data from most of the tables is pulled and outputted to a gridview. I have taken a screenshot of my gridview output for reference.
http://postimage.org/image/vncyu4oet/
As you see I have the 'edit' and 'delete' buttons on the table. There are two main things that I want to know how to do, and I have probed all over the web and haven't been able to find a solution.
1) When I click 'edit' I want only one row to be affected (which I have working), and I also want only certain cells to have the ability to be edited (namely the Date, Workout Name, Weight, and Repetitions), while the other ones can't be. Is there a way to restrict that? Lastly, once the user inputs data, how do I then update the multiple tables all at once? I have seen code on how to edit just one table, but my gridview pulls data from multiple tables like I said.
2) When clicking 'delete' I just want that row to be affected, not all the other rows that have a matching date, matching workout name, etc.
Any help is appreciated!!
I m a newbie to C# and Ive got this doubt please help.
I have these 2 webpages lets call them pageA and pageB .PageA has got a table(used DataGrid) displaying all the fields of a table in sql server ,it has got an additional edit column which displays a link to PageB, the url for pageB has got a query string which contains the ID of the product that is to be updated .In PageB i have got an update form. The form fields of which is already filled (i.e im retrieving data using the ID from the query string using "select").This pageB has got a button which is supposed to update the fields that were edited in this page and store them back to the server .
In pageB :the Page_Load() is where i save the ID to a variable (VarID) and i call the method fill_data_fields() which does the "select" and fills the fields .I ve also got the update_click() which is called when i click the button on pageB it is in this method I ve written the code to update the fields in database .
The PROBLEM is ,that the method update_click() is never called when i click the button.
Any chance that you're adding the button programmatically rather than defining it in the asmx markup? ASP.Net is horrible with dealing with that issue. Also make sure you've wired your update_Click() button correctly in the asmx markup as well. Remember, C# is case sensitive!