detailsview does not show all data in one page - c#

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.

Related

List data in multiple views edit data on click

I'm trying to figure out what design object to use for my forms application.
I want to make a forms application that looks like below image.
I have so far used splitcontainers for the layout and three gridviews with separate DataSources querying the same table but with different where clause for eatch gridview. This works fine but when i click a row in any of the three gridviews i cant have that data show on the right side becaus i can only get data from one datasource on my labels and textfields etc.
I guess that i should use one datasource but in some way have different where clause to each gridview but i've tried it and i only end up with the same data in all of the gridviews.
If it's to complicated to get together i would instead have a new form window apeare with a click of a button. So if i select one row in any of the gridviews and then click edit a new forms window will open for me to edit data in. How can i do that?
Please advice me how i should try to build the application.
For example; Dont use gridviews use this or that instead. Dont use splitcontainers use this instad. Use bindingsources... etc.
I really appreciate any help you can provide

Ways to detect changed account/no account found in ASP.NET/C#

I have an ASP.NET page where at the top of the page is a search box. There are 2 text boxes - one is an autocomplete extender for the Name on a database, and one is just inputting the ID.
The page features DetailsViews and GridViews primarily, and even when no account has been searched for, these display blank data which is not ideal. I sort of fixed this by using if (IsPostBack), encasing the elements in a placeholder and setting it to visible only if the page ispostback. But this doesn't cover if the user types in an incorrect ID.
Also, some accounts have huge amounts of data inside the GridView's. I had an issue where because I have no way of detecting when a data source's rows has changed, I end up binding whenever the page loads (Page_Load method). I've come to realise this is simply very bad - there are lots of times when the user can click various things in the page and have the page postback, and it takes an eternity to load each time I click something for accounts with lots of data.
Anyway, my question is essentially two-fold but I have a feeling the solution will be similar:
1: How can I detect when there are no accounts returned when searching, and disable the Grids/Detailsviews and show an error message?
2: How can I figure out when the user searches for another account and only rebind the grids after that has happened?
Thanks
This method is very ugly but it'll get the work done.
1) To Check whether there are no records; after the AutoComplete Extenders Webservice is called if no record is returned put some value in Session like
Session["NoData"]=true;
if Records are found then;
Session["NoData"]=false;
after the webservice is called do ajax request to check that session & on the basis of value do what you want.
2) You can achieve this also by following the above option.

Inserting , updating and deleting of Data

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.

Transferring Gridview data to another page

I have one page (Products) that searches for products which are then displayed in a gridview. Lovely stuff.
I then have a second page that is essentially a feedback form (Feedback). So therefore, a person should be able to search for a product, see its details in a gridview and then click on a hyperlink taking it to the feedback page. Upon arriving at the Feedback page, the product they were previously looking at (the gridview as it was) should be visible.
What I would like to do is transfer the gridview 'as is' (i.e. on what the person has searched for) to the second feedback page.
How would I go about achieving this?
Alternatively, if you could think of a better method for achieving the same effect (i.e. producing a feedback scenario), I am open to ideas. I could offer the feedback in the same page but I don't think it would be aesthetically pleasing with the page layout.
Please note, I appreciate that I could add an 'edit' element to the gridview itself but this is not approriate in this current scenario.
The simplest way to do this would be to make the original form and the feedback form the same ASPX page. You would simply hide or show elements, as you wish (using the Visible property). The grid view data would be persisted via ViewData.

C# gridview nested in repeater update

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.

Categories

Resources