I want the user to submit a message, and that message will be automatically added as a table row. Is it possible?
I want to do this:
Table table=new Table. table.Rows.Add(row)
Then I want to be able to insert a label into that row. For example:
row.Add(table)
But I can't find a way to do that.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.table.aspx
I want the table to grow one row bigger than it used to be with a label of the users newly added message.
I know that forums use tables, but their table seems to be growing with every message submitted.
How can I achieve the same effect with C#?
You did not provide enough details to say for sure, but almost absolutely yes.
If the HTML is dynamically and explicitly generated by you, then yes. Insert it in there.
If you are using a non-constant DataSource, then yes. Insert it in there.
The only reason it would not be possible is if the page is static, or if the data source is constant. And both of those are changeable.
Related
Below is my 46 asp.net control including textboxes and dropdownlist to insert data in single button
Below is my asp.net control id as above image given image
ddl_tag1 txt_date1 ddl_type1 txt_narration1 txt_amount1 txt_bill1 txt_fromloc1 txt_tolocation1
ddl_tag2 txt_date2 ddl_type2 txt_narration2 txt_amount2 txt_bill2 txt_fromloc2 txt_tolocation2
ddl_tag3 txt_date3 ddl_type3 txt_narration3 txt_amount3 txt_bill3 txt_fromloc3 txt_tolocation3
ddl_tag4 txt_date4 ddl_type4 txt_narration4 txt_amount4 txt_bill4 txt_fromloc4 txt_tolocation4
ddl_tag5 txt_date5 ddl_type5 txt_narration5 txt_amount5 txt_bill5 txt_fromloc5 txt_tolocation5
ddl_tag6 txt_date6 ddl_type6 txt_narration6 txt_amount6 txt_bill6 txt_fromloc6 txt_tolocation6
below is my table structure the above six row data insert one by one into below format
Sno TAQ DATE TYPE NARRATION AMOUNT BILL FROM LOCATIOM TO LOCATION
What is the best way to insert data using add button, i have to use for each loop for insertion for above text boxes and drop-down to insertion one row then another row insertion.
If you are manually putting a bunch of controls onto a page, and not databinding them to anything, creating six manual insert statements is pretty much the only option as far as I know.
As one commenter said above, a gridview might be easier, but honestly if the point is solely just to add and not to also display/update (which is what gridviews are best at) I'm not sure how much that would gain you. If the requirement is specifically and only to add six new rows at a time, you're probably doing the easiest thing.
If you ultimately want more functionality than just add records, you may want to take a look at gridview though.
I have an asp.net gridview that populates from a table and has the edit functionality enabled. Im not sure if there is anything built into sql that I can use for this limitation, or if I am going to have to make a time stamp column to keep track. If that is the only method how would I integrate that into the gridview?
im not sure the best way to go about doing this.
It might be an option to populate two gridviews, one pulling the editable rows (not edited in the last 24 hr) and the 2nd being the ones they edit. the only difference being the select statement for each. im not sure this is the best way tho.
The columns are PK (primary and identity), ResidentName, ResidentAddress, VisitorNumber, VisitorName. I can add a datetime column if I need to.
thanks
mike
If you working with DataSet in c# there is methods to check changes using ds.HasChanges() and also you can get changed rows by using ds.GetChanges(). Can check rows Added or Modified. Thereafter you can bind ds to DataGridView.
From time to time, I need to create an input control which allows multiple rows of input, the type of input and number of columns could be different in each case but typically it would be represent a database table being edited, so it should also be possible to store an id value within each row. It should also be possible for the user to add new rows to the input if they have more data to input.
I have tried a couple of approaches to this but they are all very long winded for what seems like such an obvious and common scenario. I'm thinking that there must be a simple way to do this that I have missed.
The way that I usually solve this is by using a list view, enter all of the input controls required within the item template and use a html table for formatting, with each item being a row of the table. If there is existing data to be edited, I would load the data from the database, add a blank object to the results and bind it to the list view. If there is no existing data, I would create a collection with a blank record in it and bind it to the list view. I add a button for adding a new row. When clicked, this button retrieves all of the existing data from the list view by iterating all of the listview items and populating the data into a collection, which I would then add a blank object to and rebind the listview with the results. When saving, I would retrieve the results by iterating the listview items again and using a hidden field within each row to store the record id. This would determine whether a new record was added or an existing record was edited.
This approach works for me but I'm sure there must be simpler ways to achieve this. Looking forward to seeing how other people solve this.
For web forms, use a GridView. You can set its properties to allow editing, deleting, new rows, sorting, and paging.
Check out the MSDN example here that shows how to use it. If you bind a datasource to it, it will figure out the columns and adjust dynamically then, or you can predefine the columns you want for more customability.
You are talking about bulk insert/update. You could use XML insertion/updation for this purpose. Get all the data to a DataSet ds variable. Then use ds.GetXml() method to convert the dataset to XML string. Pass this to an XML parameter into SQL server which has the datatype 'XML'
INSERT INTO YOURTABLE
SELECT
V.VOI.value('(.)[1]', 'int')
FROM
#Input.nodes('/DATASETNAME/DATATABLENAME/') V(VOI)
Use this link to learn more
You need dynamic table with Add, View,Edit and delete operations on each data.
I would suggest using DataTable Jquery component. there are tons of examples on Data operations, and you can plug this with any Server technology including ASP.net
http://editor.datatables.net/
I've been trying to figure out for a long time now how to create an interface that can allows users to input several rows of data and pass those entries into an SQL server database all in one shot. I could not get any better ideas so I came up with this (see picture below).
What I envisioned is that the user enters values in the textboxes and hits the "add to list" button. The values are then populated in the list box below with the heading "exhibits lists" and when the add exhibit button is pressed, all values from the list box are passed into the database.
Well, I'm left wondering again if it would be possible to tie these values from the textboxes to the list box and whether I'd be able to pass them into the database.
If it were possible then I'd please love to know how to go about it otherwise I'd be glad if you could recommend a better way for me to handle the situation otherwise I'd have to resolve to data entry one at a time.
I believe there is some useful information from this website that can help solve my problem but I just can't make heads or tails of the article... it seems like I'm almost there and it skids off. Can everyone please read and help me adapt it to my situation? Post below:
http://www.codeproject.com/KB/aspnet/ExtendedGridView.aspx
Yes, it is possible. I have done this twice before.
Check out the "Data Access Tutorials" at http://www.asp.net/web-forms/data for ideas.
Overview
For the user-interface, you want a data-entry-form above a data-grid.
For the back-end, you want a data-adapter (or table-adapter) that loads and saves data to the database in one operation.
You would use a DataSet and DataAdapter to update the database, and manipulate a DataRow for the input and a DataTable for the list-box. Note the list-box is actually a data-grid, repeater, or other control that accepts a DataTable as a DataSource.
The DataAdapter fills the DataSet which contains the DataTable.
The input controls bind to a DataRow created from the DataTable. When the user clicks add-to-list, you add the data-row to the data-table, then create a new data-row for the next item.
When the user clicks add-exhibit, it is a simple matter of using the DataAdapter to update the database. Any changed, deleted, and added data is handled for you.
You could use a transaction to encapsulate all the sql queries you are trying to run, so you can then just 'commit' the transaction in one to the database? Are you still having difficulty with this issue?
Before anyone suggests scrapping the table tags altogether, I'm just modifying this part of a very large system, so it really wouldn't be wise for me to revise the table structure (the app is filled with similar tables).
This is a webapp in C# .NET - data comes in from a webservice and is displayed onscreen in a table. The table's rows are generated with asp:Repeaters, so that the rows alternate colers nicely. The table previously held one item of data per row. Now, essentially, the table has sub-headers... The first row is the date, the second row shows a line of data, and all the next rows are data rows until data of a new date comes in, in which case there will be another sub-header row.
At first I thought I could cheat a little and do this pretty easily to keep the current repeater structure- I just need to feed some cells the empty string so that no data appears in them. Now, however, we're considering one of those +/- collapsers next to each date, so that they can collapse all the data. My mind immediately went to hiding rows when a button is pressed... but I don't know how to hide rows from the code behind unless the row has a unique id, and I'm not sure if you can do that with repeaters.
I hope I've expressed the problem well. I'm sure I'll find a way TBH but I just saw this site on slashdot and thought I'd give it a whirl :)
When you build the row in the databinding event, you can add in a unique identifier using say the id of the data field or something else that you use to make it unique.
Then you could use a client side method to expand collapse if you want to fill it with data in the beginning, toggling the style.display setting in Javascript for the table row element.
just wrap the contents of the item template in an asp:Panel, then you have you have a unique id. Then throw in some jquery for some spice ;)
edit: just noticed that you are using a table. put the id on the row. then toggle it.