Displaying all the data without using databound controllers ASP - c#

I have a table named "Rezervare" with the field id, id_hotel, data_inceput, data_sfarsit, pret.
My task is to display all the records without using databound controllers . Afterwards I need to update and delete them so I need to select specific id's to do those operations.
Since I am new to C# and ASP I don't know how to display and make buttons that would take the right id on press in order to delete or update a record in the table.
To sum things up I have 2 questions:
How do I display the data in the table without using listview,detailsview,formview etc.?
How do I make buttons for each of the item that on press take the right id(just like in listview would)?
(I don't know the answer to the 1st question so that answer might just answer my 2nd)

Related

Insert large asp.net control data row wise into sql table using asp.net c#

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.

How do I create a gridview with an empty column to allow user to enter a value which will then be used with the rest of the columns to update a table

How do I create a gridview with an empty column to allow user to enter a value which will then be used with the rest of the columns to update a table. I was hoping to allow user to go down a gridview change a number of values and upon button push have the new table displayed to review changes before submitting to a database. The gridview is dynamically bound from an ilist which makes it difficult as the page lifecycle disables me pulling the items out using .findcontrol. And Neither can I use viewstate("newtable") = ilist method as this will not account for the editable field. Help!!!
J
Firstly, your question is not clear if you put your code sample it will be more. if you work with entity framework for database op., datagridview already allow updates. yourentityobject.SaveChanges() is enough.

make an interface with datagrid

I am making a windows form application, a billing software. I want to make a interface like this on one of the forms:
There is a row of textboxes with about 5-7 textboxes, i fill the first textbox with a product ID which automatically populates the rest of the textboxes fetching data from appropriate tables and automatically generate a new row of textboxes, the first textbox from the new row being focussed for entering product ID. It should continue until i click a certain button which finalizes the bill. On clicking this button all these values should be updated to database in respective tables. How can I achieve this?
Can using datagrid help?
Google "C# write to database" and click on one of the links, like these that came up when I did it:
http://www.codeproject.com/Articles/3554/Simple-Database-Application-Part-1
http://www.codeproject.com/Articles/1155/Simple-ADO-NET-Database-Read-Insert-Update-and-Del
Or go to amazon.com and search "c# database" and buy one of those books.

Update a data row inside an asp.net Data Grid View

I think it would be easier for you to understand my problem if I explain the scenario a bit.
What I am doing is developing a system to a doctor using asp.net c#. For the creation of the prescription, I add a check box list for the list of medicines and submit button below it. When the submit button clicked selected check box list items added to the sql server database and show a data grid with the selected medicines in the same page.
In the data grid there are two columns for medicine name and dosage.Medicine name is taken from the database.I need to give the user the ability to enter the dosage through that grid view. I need to use update command because the record is already there in the sql server.But empty value in the dosage column.I tried to use update command in the data source control. But I can't figure out how to give the WHERE clause because I can't specify the database row which the updating record relate to.
I would be glad to hear some help from you. All the comments are welcome.
You need to set a parameter(s), please check this example to understand how it works. I guess, that you've added in the database some column that is unique identifier.. some autoincrement int or guid.

Cleanest way to implement collapsable entries in a table generated via asp:Repeater?

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.

Categories

Resources