I want to make a control that show list of bounded data like in grid view but I want to be able to insert new record from the same control
what is the best asp.net control I can use to do that (GridView , FormView or DetailsView)? and why?
Thanks in Advance
You can do that with all three. If you want to know how, there are some good tutorials on the official ASP.NET website, here.
The choice between them is a formatting/layout decision. A GridView produces a table, showing multiple records, while a DetailsView shows one at a time. A FormView lets you display the data however you want, but required much more effort, since you have to provide the HTML.
Related
I want to list data with repeater from database on a server. There are nearly 5000 data in the database. When listing this data with repeater, the page loads a bit late. How can I quickly list data?
Thanks..
Simple: don't try to display so much data in one list.
No user is going to scroll through 5000+ records to find the one they want.
Use paging, and provide options for the user to filter the returned data.
NB: Whilst you can add paging support to the Repeater control, it's not supported by default. You would probably have better luck using the ListView control instead, combined with a DataPager control.
I am trying to show the sum of totals for different kind of invoices on a web page.
I am using detailsview control, however it does not show all the data in one page. When I enable paging the other types of invoices can be seen on 2nd and 3rd pages.
My SQL command is:
SELECT CARI_HESAP_KODU, FATURA_TURU, SUM(KDV_MATRAHI) AS TUTAR FROM LNX_STD_6_016_01_SLSINVOICES WHERE CARI_HESAP_KODU=#mKodu GROUP BY FATURA_TURU, CARI_HESAP_KODU
When I run it from SQL I get the proper results:
But when I run the page and test detailsview I get:
So I have two questions:
1. Is it possible to show the results as columns (as in SQL view) instead of rows?
2. Is it possible to show all the records in one page?
Thanks in advance.
As stated in the comments by Esko, the details view only shows one record at a time. The details and Grid views are fast easy ways to display data, however if you wanted to customize how data is displayed, a more generic repeater would be the next logical choice, you would just have to do the formatting yourself.
Check out his article or google "asp.net repeater":
https://msdn.microsoft.com/en-us/library/zzx23804(v=vs.85).aspx
When I used to program in web forms a lot, I used repeaters even when a details or grid view would have done the job, because they are much more flexible and easier to maintain when someone asks for changes.
Cheers.
So my question is this, I have a gridview that filters data from a database when a search keyword is entered. The problem is, that I need it to show some 20 different fields, which is significantly too long for a web page. The gridview goes beyond my asp.net webpage width and off of it. I was wondering if there was any way I could make it neater and easier to read, or fit all the data fields on one page. I'm not too familiar with this, so excuse my lack of know-how in and thank you in advanced.
A few suggestions:
Show fewer fields.
Make your columns really narrow.
Make your grid a header row only (contains only minimal info for a record). Clicking a link in a row will display further details for that item.
Use a DataList, Repeater or ListView so you can layout the row yourself.
You can try something like this:
http://weblogs.asp.net/dwahlin/archive/2007/07/31/freeze-asp-net-gridview-headers-by-creating-client-side-extenders.aspx
I think this thread on another site addresses exactly what you're asking:
http://forums.asp.net/t/1277793.aspx/1
I have created a databinding treeview which binds with multiple tables and display hierarchical data. I stole much of the mechanism from http://www.codeproject.com/KB/tree/dbTree.aspx if it interests you.
I first merge(outer join) all the datatables into a big datatable, then databind the treeview and bunch of textboxes to the big table. User can click on a node in the treeview and see corresponding info in the textboxes. So viewing part is nice.
Now coming to updating, deleting, adding info via textboxes entries, is there a way the user can make changes via the textboxes, and immediately reflected in the big table and individual tables ?
Thanks!!
You are joining information in a kind of view and I understand that this view is stored in memory while you fill your tree. So, if you do any kind of change in the data inside the tables that composes your view, you must reload it.
If you are working with an web app, it is going to be something natural, because each user interaction will do a new request to create you view.
My current situation is to display an unknown number of Plantypes and within those Plantypes display a list of Participants(also unknown number), the participants have a textbox and a dropdown that is editable (you can't edit the individual rows, there is one update that does a bit of validation then updates all rows.)
I currently have a gridview nested withing a repeater, the repeater displays the Plan in a label and OnItemDataBound I call a method to populate the gridviews. It looks great, but I can't figure out how to save all the data at once. I'm not opposed to handling this a different way, as in loose the gridview and or repeater, if someone has a better idea.
This is C# and framework 2.0...there is no sorting or paging on the gridviews...just some links and the fields to update.
thanks in advance,
Padawan
HTTP is stateless. Since a user physically can only update one record at a time you should implement some way to save as the user goes. This can be a simple as having a row focus and row blur events and do the saves using AJAX on blur(unfocus). Maybe make is modal as they edit so they cannot leave the page without saving.