How to count total number of results return by list and display - asp.net-mvc

I am using MVC 4.
I binding result in grid based on my search criteria in web grid. and i am showing 10 records per page.
the question is.
How can i show the total count of records below the grid.
i tried counting the result list in control and show it in view.
if i use
#Html.TextBoxFor(m => m.NumberOfRows)
it returns result in the text box
but if i use label means if shows property name instead of total count.
#Html.LabelFor(m => m.NumberOfRows)
Why label show property name. How can i show the total count. or is it possible to show the total count in web grid itself?
please help.

LabelFor() in MVC is used to display model property names,so instead using LabelFor(),if you are binding value to NumberOfRows from controller action then
Instead of
#Html.LabelFor(m => m.NumberOfRows)
Try
#Model.NumberOfRows

Related

Automatically fill out textbox doble clicking on an item in a listbox

Another beginners question, but this time about MS Access Controls.
I have a form where I have a list box full with many items.
What I need to do is when I double click on one of this item stored in the list box should all the textbox filled with an item stored on a different field from the same row where from my table.
I checked many tutorials already but didn't found a good solution.
Thanks for any help!
EDIT:
I have a table with several fields. The list box have the items from the first field(ID). The rest of the fields(Tile, Delivery Date, etc...) represented by text boxes in my form.
When I double Click on one item from the list box will populate the text boxes.
If I select the 5th item from my list box which represents the 5th row from my table every text box should have their item from the same row from the fields represented in the table.
I only want to edit the data stored in the table with this form.
Ok I finally get a solution for this one.
I using the DLOOKUP to get the data pulled to my form after the double-click event.
Dim ctrloop
For Each ctrloop In Me.lbReportID.ItemsSelected
strReportID = Me.lbReportID.ItemData(ctrloop)
Next ctrloop
Me.txtTitle = DLookup("[Title]", "tblreports", "[ID No] = '" & strReportID & "'")
The loop stores all report ID I have in my table. The DLOOKUP using this as a filter. It's like the WHERE in SQL.
When the program run will fill out my Title textbox looking through the title field in my tblreports table filtered with the strReportID.
It's working similarly like this SQL query which I using in a different textbox:
SELECT tblReports.[ID No]
FROM tblReports
WHERE (((tblReports.WorkPacage) = 'CDS'))
AND (((tblReports.State) <> 'Complete'));

do some calculations in a table using dropdowncombo

I have a field in my database called 'Stock'. It displays how many items are there remaining for sale.Now I have a dropdowncombo with values like 1,2,3 etc... So now when I select an item in the grid and click the button SELL I would like the 'Stock' field of the item in question (in the grid) to decrease by the amount that was in the combo. So if the 'stock' was 100 and I sell 5 (dropdowncombo value) I would like the grid value to display now 95. I hope you know what I mean... I could do this with inserting a calculated field but I do not want to. Better an UPDATE ... Any ideas
something like UPDATE MyTable set STOCK = (Mytable.fieldbyname('stock').asInteger - dropdowncombo1.value)
dont have delphi here with me so unsure does this work on selected record in the grid...
abstable1.edit;
abstable.FieldByName('stock').value := abstable.FieldByName('stock').value - strtoint(cxcombobox1.text);
abstable1.Refresh;
This does the job ...

KendoUI grid display total number of records

I am using the kendoUI grid to show records from a table. I would like to display the total number of records so the table. something like
showing 1-20 of 1203 records
is there a way to show the total number of records using KendoUI grid?
All you have to do is add this to your .kendoGrid
dataBound: function (e) {
//total bits needs to be removed because dataBound fires every time the gird pager is pressed.
$('#totalBits').remove();
//add the total count to the pager div. or whatever div you want... just remember to clear it before you add it.
$('.k-grid-pager').append('<div id="totalBits">' + this.dataSource.total() + '</div>')
}
The MVC wrapper code I used to display a footer(pager) with only the record count looked like this:
#(Html.Kendo().Grid(dataSource)
.Columns(...)
.Pageable(p => p.Numeric(false)
.PreviousNext(false)
.Messages(m => m.Display("Matching Students: {2}")))
You can use the option pageable.messages.display, you can review the documentation: Here

Getting the current item number or index when using will_paginate in rails app

I have a rails app that stores movies watched, books read, etc. The index page for each type lists paged collections of all its items, using will_paginate to bring back 50 items per page. When I output the items I want to display a number to indicate what item in the total collection it is. The numbering should be reversed as the collection is displayed with most recent first. This might not relate to will_paginate but rather some other method of calculation.
I will be using the same ordering in multiple types so it will need to be reusable. As an example, say I have 51 movies. The first item of the first page should display:
Fight Club - Watched: 30th Dec 2010
Whilst the last item on the page should display:
The Matrix - Watched: 3rd Jan 2010
The paged collection is available as an instance variable e.g. #movies, and #movies.count will display the number of items in the paged collection. So if we're on page 1, movies.count == 50, whilst on page 2 #movies.count == 1. Using Movie.count would give 51.
If the page number and page size can be accessed the number could be calculated so how can they be returned? Though I'm hopeful there is something that already exists to handle this calculation!
It feels a bit hacky, but I've come up with a working solution. I create an instance variable in the view:
#count = #movies.total_entries - #movies.offset
Then when rendering each movie I output #count and decrement it.
As per my previous example with 51 items on two pages: total_entries == 51, and offset == 0 (page 1) or 50 (page 2).
Have a look at the built-in function:
<%= page_entries_info #posts %> #-> Displaying posts 6 - 10 of 26 in total

Delphi QuantumGrid GetSelectedRowIndex after sorting

I have D2006 and I am using DevExpress QuantumGrid 6 in a project. I am using it in unbound mode. I have several rows and I need to trigger an action when user select a row and click a button. That works fine when the grid is not sorted by user. I use this code to know the row the user has selected:
index := cxMainTable.DataController.GetSelectedRowIndex(0);
cxMainTable.DataController.Values[index, 0];
But when the user sort the grid by clicking in a column header, the index returned is right for the current order displayed but the values the second line returns is the value that you would expect if the grid was not sorted.
Thanks.
You have to distinguish between records and rows.
Maybe TableView.DataController.FocusedRecordIndex is what you want?

Resources