Forms Data Controls :: Sortable Aggregated (computed) Column In A Gridview?

Jan 11, 2010

I have stumbled into a problem in which Im having a hard time solving. I have a linq data setup(based on a mssql) where a Purchase Order contains a number Equipments - each equipment has a price. I have a gridview that shows the summed price of the equipments that are included in a Purchase Order. This sum is currently being calculated on RowDataBound through a "listOfEq.Sum(Eq => Eq.PurchaseOrderPrice);" expression which works without any problems. My problem is that I want to be able to sort the gridview based on this summed value, which I cannot do with a normal sortexpression. My next thought was to create a function in my database to calculate the sum instead and then use this is my data basis for the summed column. I have created a function like this:

[Code]....

I want to create a sortable column based on this data. My thought is something like this:

[Code]....

Displaying the correct information is not a problem, however creating the sorting is. Im not sure what to put in the SortExpression. Anybody got an idea of what to do? Perhaps I am forced to use a computed column for this however I dont know to create this column when its based on another table. If this is the case, any idea about how to do create a computed column thats based on data from another table?

View 2 Replies


Similar Messages:

Forms Data Controls :: MS SQL 2005 And DataSet - Computed Column

Feb 16, 2010

I have a datatable in MS SQL that has FirstName and LastName. In MS SQL I created a computed field called FullName that was ((rtrim([LastName])+', ')+rtrim([FirstName])) I created a DataSet and a Business Logic Layer. In my typed DataSet I saw FullName in the listing when I created it. I am able to use FullName in my webpage. I use it to populate a dropdownlist. However, now when I make changes to the Customer Table I am getting this error message (seen below)

Question: Should I have created the field FullName in my MS SQL Table or should I have left it alone and somehow just added a column to the DataSet and placed an expression in the FullName column? The column "FullName" cannot be modified because it is either a computed column or is the result of a UNION operator. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: The column "FullName" cannot be modified because it is either a computed column or is the result of a UNION operator. Source Error:

[Code]....

Source File: c:Users ottfarmsAppDataLocalTempTemporary ASP.NET Filesinternalauburnriverside98ea0e1f2a7f0720App_Code.lbdcba1v.2.cs Line: 1240 Stack Trace:

[Code]....

View 1 Replies

Column In A GridView Computed On The Fly?

Jan 25, 2011

I have the following GridView:

<asp:GridView ID="gv" AutoGenerateColumns="false" runat="server">
<Columns>
<asp:BoundField DataField="productName" HeaderText="Item" />
<asp:BoundField DataField="unitCost" HeaderText="Cost" DataFormatString="{0:c}" />
<asp:BoundField DataField="originalCount" ItemStyle-HorizontalAlign="Center" HeaderText="Old Count" />
<asp:TemplateField HeaderText="New Count" ItemStyle-HorizontalAlign="Center" >
<ItemTemplate>
<asp:TextBox ID="NewCount" Width="20" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

And I want to add a final 'Total' column that calculates (originalCount - NewCount) * unitCost and updates it as the user enters a number in the NewCount text box. Can I do this just with .net, or do I need to use Java? If the latter, how do I tell which Gridview cell to update?

View 1 Replies

Forms Data Controls :: How To Make A Gridview Header Fix And Sortable

Mar 25, 2011

how to make a gridview's header fixed and sortable. All the solutions I've seen do one or the other, but not both. If I put the header in a separate table, I don't know how to make it sort. None of the CSS options I've seen work either.

My gridview isn't anything special, but it is databound via a data accessor in c#.

Here's the grid:

[Code]....

And the code behind:

[Code]....

View 6 Replies

DataSource Controls :: Make Computed Column That Reads Its Latest Value And Increment It By 1

Feb 2, 2010

I'm trying to define a computed column that will contain an auto-incremented number. In other words, I want it to work exactly like identity, but since I can have only one identity column per table, I wanted to make a computed column that reads its latest value and increment it by 1.

View 5 Replies

DataSource Controls :: Add Read Only Computed Column In Linq To Sql Designer (dbml)?

Feb 7, 2010

How do add read-only computed column in LinqToSql designer (dbml)? My existing table structure:

Name: ID, Type: int, AutoGenerate: true, AutoSync: OnInsert, PrimaryKey:
true, ServerDataType: int not null identity, Source: IDName: Name, Type: string, ServerDataType: nvarchar(100) not null, Source:
NameName: Value, Type: byte[], ServerDataType: VarBinary(max), Source:
Value, UpdateCheck: Never

I want add the 4th colum name: Name: HasValue, Type: bool --> [Value] != null

View 1 Replies

MVC :: Sortable Table / User Click On The Column Header And Sort The Column They Want?

Mar 25, 2011

i have a table which showing the food data from my Model, including Name, Amount, Storage and Expiry Date. I wish to either:

1. Let user click on the column header and sort the column they want

2. Or default showing the food which almost expired on the top of the table

View 4 Replies

DataSource Controls :: SQl Query - Generate Another  Computed Column That Will Contail The Result Of GrandTotal/Total?

Jun 30, 2010

How do i generate another computed column that will contail the result of GrandTotal/Total,


where GrandTotal is another value comes from computed column and the Total would be the sum of the Total within SchedularID.

And thats what i have done so far: [Code]....

View 3 Replies

Data Controls :: Search DropDownList And Textbox With Sortable Header In Custom Paging In GridView

Apr 27, 2016

I am going to use this article but I don't know how to add the Search which is the dropdownlist and textbox

The data in dropdownlist is ContactName and CompanyName

[URL]

Also I would like to know how to sort the gridview in Header

View 1 Replies

SQL Server :: Computed Column In Sql

Dec 16, 2010

I have a column that contain date (of type datetime), i also want to add another column that will contain 1 Or 0 depends if the value of date has passed the current date or not.

View 4 Replies

SQL Server :: Filter By Computed Column

Aug 17, 2010

After looking for a driver to open legacy dbf drivers to connect, the next level trouble a have is this one: first, i can retrieve the data but when trying to filter by a parameter (somesc columns) i get an error. The error says about the database can't determine. The error is a columm tha is formated ( 1234 ) about 8 space, fixed. The values in the query appears like that. I resolve this by Trimming Ltrim(ColumnName) and i get this (1234). Now in SqlExpress, how can i filter by the new Trimmed Expression? (This is a primary key that the DBF use)

Sample:
SELECT column1, column2, column3
TABLE FoxProDB

Now

SELECT Ltrim(column1) as NewExp, column2, column3
TABLE FoxProDB
Where NewExpre = @NewExpres -Error-

View 2 Replies

Computed Time Column In SQL Server

Nov 21, 2010

Using vs2008 I have a SQL Server database attached to my web app. I want to use a computed time column in the database, along the lines of :

timenow is 1 column
hoursleft is another column
timeend would be another column.

I want timeend to = timenow + hoursleft. Is it possible to do that, and if so what would the formula be that I would enter into the computed column field, and, what datatype would the columns be, timenow and timeend I would expect to be time(7) and hoursleft an int. But is that correct?

View 2 Replies

MVC :: Computed Column Vs Field In Partial Class?

Jun 28, 2010

I have a table of people with columns holding bits of info about them. I also need a variety of computed columns such as FileAs (lastname + ", " + firstname) and CityStateZip (you get the idea). I am wondering where best to put these definitions. It's worthwhile to note that the user will want to search for things as seen on the page, not the little atoms in the table. For example, searching on ", e" finds everyone whose first name begins with E. Typing ", az" to get everyone who lives in Arizona.

I noticed that linq-to-sql queries only recognize the fields in the table definitions, not any that are added in the partial class associated with the dbml. Linq-to-sql does work against computed columns in the database; however, the column definitions--especially for international address formats--will become very complex and much better handled in code.

View 3 Replies

Create Computed Column With String In Formula

Oct 23, 2010

I want to create a computed column in SQL SERVER and set the formula to this

([Category] + '.aspx?ID=' + [Post_ID])

Not working though......what am i missing? Category and Post_ID are current columns in the table

View 3 Replies

C# - Easiest Way To Make Only One Column Sortable

Oct 12, 2010

I have a datagrid with sorting. I set enable sorting to true, but that makes every column sortable. Is there a simple way to make it so that only one column header can be clicked for sorting? I feel like there should be a simple and quick fix for this, but who knows. some code:

<asp:GridView ID="ProductsGrid" runat="server"
AutoGenerateColumns="False" Height="323px"
style="margin-top: 23px; margin-left: 0px;" BackColor="White" CellPadding="0"
Width="1210px" OnPageIndexChanging="gridView_PageIndexChanging"
onrowdatabound="ProductsGridView_RowDataBound" AllowPaging="True"
PageSize="25" AllowSorting="True" OnSorting="ProductsGrid_SortCommand">

I then have several columns. Is there something I can set in the code for the column to disable all others or only make one sortable?

View 1 Replies

SQL Server :: Set The Computed Column Into Inbuilt Database Into Vs2008?

Sep 16, 2010

i have designed a database into the vs 2008 mobile database. my batabase has three column column1(int),column2(int),column3(int) and i want to set the value of val(column3)=val(column1)+val(column2); how and where to set the computed column value.

View 2 Replies

Forms Data Controls :: >>>want To Display Gridview Column Heading When Mouse Over To The Particular Column In The Gridview?

Oct 12, 2010

I want to display gridview column heading when mouse over to the particular column in the gridview.I am working in VisualStudio 2005 with MS.Net2.0 framework.I don't want to use ajax.

View 4 Replies

Forms Data Controls :: Gridview 2nd Column Decrease After Expanding The 3rd Column's Gridview?

Oct 29, 2010

[Code]....

Main Gridview[Code]....

View 3 Replies

Forms Data Controls :: Paged Sortable Lists And Efficiency?

Jan 13, 2010

I need to make a large Ebay-style list of listings (think of the page that comes up when you search for something in Ebay, with a photo, title, one-line description, price, that's paged, and sortable). My limited experience with DataGrids in the past always resulted in what felt like a sluggish page to me, but I'm not sure if it would have been faster if I had pieced it together with a data reader instead.So I'm wondering before I even get started, what is the fastest / most efficient way to retrieve and manage this data.Is it more efficient at runtime to use a DataGrid, or to write the paging and sorting in more manually and use a DataReader, or another way?Ebay manages to get thousands of listings to display very quickly, but they've obviously got a lot of manpower to squeeze every last bit of performance they can out of the site, and good high-powered servers.

View 5 Replies

Forms Data Controls :: Gridview Column Change / Replace A Column Data Field Value to 'Not Applicable'?

Jan 6, 2011

I have a gridview which is binded to a Sqldatasource. I would like to replace a column data field value to 'Not Applicable' if that column has got a value of 2 in database.

View 2 Replies

Forms Data Controls :: >>>Display Gridview Column Heading When MouseOver On Particular Column?

Oct 12, 2010

want to display gridview column heading when mouse over to the particular column in the gridview.

View 9 Replies

Forms Data Controls :: Add A Button At First Column Of Gridview And Get Cell Value In Another Column

Jul 22, 2010

How to add a button at first column of gridview and get cell value in another column?

For example, add a button named it as "Click me". Once user clicks will get third column cell's (ID) value.

View 2 Replies

Forms Data Controls :: Make A GridView Column Invisible If Every Cell In That Column Is Empty?

Mar 4, 2011

No sense in showing a competely blank column. how to make a GridView column invisible if every cell in that column is empty?

View 3 Replies

Forms Data Controls :: Display Text In 2 Rows And Then A Gridview Column - Third Row Is Displayed As A Row Under First Column

Jul 14, 2010

I have a gridview with 3 columns. In second column I want to display some text in 2 rows and then a gridview.
Here is my code:

[Code]....

The problem is my third row is displayed as a row under first column. How do I make it a separate column in my girdview. Not sure what is going wrong.

View 11 Replies

Forms Data Controls :: Gridview Column Validation When The Sum Of Column Value Is More Than 100?

Jan 8, 2011

I am using GridView ,I want to do a validation like if i edit any one of the Cell in that column, it will through the validation when the sum of column value is more than 100. How can i do this validation?

View 10 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved