Asp.net - Generate Columns From Distinct Values?

Oct 25, 2011

I have a three column table which lists every person, every event they may have attended, and what percentage of the time they were there. I would really like to display this on one page with the person names on the side and the event names across the top.

Here' an example of what I have:

NAME EVENT %ATTENDANCE
Smith Rock Climbing 50
Allen Rock Climbing 78

[Code]....

View 2 Replies


ADVERTISEMENT

C# - Get Distinct Rows From Datatable Using Linq (distinct With Mulitiple Columns)

Jul 13, 2010

I am trying to distinct on multiple columns and get datarows from datatable. but getting error.

Dim query As IEnumerable(Of DataRow) =
(From row As DataRow In SourceTable.AsEnumerable() _
Select row.Field(Of String)("ColumnName1"),

[Code]....

I want another datatable with distinct row based on given columns from SourceTable.

View 3 Replies

DISTINCT Output From Multi-Columns?

Aug 4, 2010

I'm trying to fill a ComboBox from 3 columns in the same table. I need output DISTINCT and the drop down box would look better if it had no spaces between groups.

Using myCommand As New MySql.Data.MySqlClient.MySqlCommand("SELECT ten_id1, ten_id2, ten_id3 FROM tenants", myTenConnection)
Dim myReader As MySql.Data.MySqlClient.MySqlDataReader

[Code].....

View 2 Replies

How To Group Distinct Columns In A Linq Query

Nov 4, 2010

The following data is created by joining two sql tables together:I would like to group together distinct rows of DateStamp/UserName/ StudentName/ InstructorName/TableName/PrimaryKey (I'll call this 'group records') and then group under these ColumnName/PreviousValue/NewValue (I'll call this 'subgroup records')The end result would be that I could iterate through the 'group records' - there would be 5. In each 'group record', I could then iterate through the 'subgroup records'. The 5 groups would contain 3, 2, 5, 2 and 1 subgroup records respectively.What would be the syntax to create a query to do this? Ideally this would be in a vb.net linq syntax.

View 1 Replies

LINQ To SQL Grouping Multiple Columns With A Distinct Row

Aug 9, 2010

I have the following table structure. I want to select distinct CustomerId and CustomerName, TotalCost.[code]

View 2 Replies

Linq To Datarow, Select Multiple Columns As Distinct?

Apr 16, 2010

basically i'm trying to reproduce the following mssql query as LINQ

SELECT DISTINCT [TABLENAME], [COLUMNNAME] FROM [DATATABLE]

the closest i've got is

Dim query = (From row As DataRow In ds.Tables("DATATABLE").Rows _
Select row("COLUMNNAME") ,row("TABLENAME").Distinct

when i do the above i get the error

Range variable name can be inferred only from a simple or qualified name with no arguments.

i was sort of expecting it to return a collection that i could then iterate through and perform actions for each entry. maybe a datarow collection?

As a complete LINQ newb, i'm not sure what i'm missing.
i've tried variations on

Select new with { row("COLUMNNAME") ,row("TABLENAME")}

and get:

Anonymous type member name can be inferred only from a simple or qualified name with no arguments.

to get around this i've tried

Dim query = From r In ds.Tables("DATATABLE").AsEnumerable _
Select New String(1) {r("TABLENAME"), r("COLUMNNAME")} Distinct

however it doesn't seem to be doing the distinct thing properly.

View 3 Replies

Asp.net - Select Distinct Rows From A Datatable With Criteria Involving Multiple Columns Using LINQ

Mar 9, 2012

I have a datatable as shown in the figure. Let me explain my required based on this image. I have 7 rows of data. The rows 1 and 2 contains columns till UnitSqcNo same. I want only row 3 among the two. In general I want select all the rows with distinct model, unittype, unit and rest with greater CompId. ie the table should look like

View 1 Replies

Get Distinct Values In Column 2 Of A DGV?

Aug 9, 2010

I am trying to get distinct values in column 2 of a DGV using the following LINQ query:

Dim AllocatedRoomTypes = From r In Me.AllocatedDGV.Columns.Cast(Of DataGridViewCell)() Select r.ColumnIndex = 2 Distinct

but I get the following error:

Unable to cast object of type 'System.Windows.Forms.DataGridViewTextBoxColumn' to type 'System.Windows.Forms.DataGridViewCell'

I understand that the problems lies with the Cast, but I do not know how to correct it.

What I am trying to acheive is this:

Value is Column 2 of DGV

Double
Double
Single
Twin

[Code]....

View 6 Replies

C# - How To Get Distinct Values From DataTable In DataSet

Dec 23, 2011

I am using strongly typed dataset and have many tables in that. The problem is now I want to filter data from
GetData()
function which has a query like
select * from table_name

How can I filter a particular table and distinct values from it. Also if I try to filter it return all column but rest have null values except the one I asked, so I cannot assign it as a datasource to a datagrid or combobox. How can I do this..

View 3 Replies

Finding Distinct Values In Array?

Feb 15, 2012

I have a database which need to be assigned into array arr()(), e.g.

arr(0)(0) = aa arr(1)(0) = ab arr(2)(0) = aa
arr(0)(1) = bb arr(1)(1) = ba arr(2)(1) = ba
arr(0)(2) = cc arr(1)(2) = cc arr(2)(2) = cc

I need to find distinct / unique value in each arr(k)(0), arr(k)(1), arr(k)(2); where k=0..2. Then i need to insert the result into array cat as follows:

cat(0)(0) = {aa} cat(0)(1) = {ab}
cat(1)(0) = {bb} cat(1)(1) = {ba}
cat(2)(0) = {cc}

I've tried code below but it doesn't work. The assigning process into array arr()() from DB is OK. Problem only come up if I try to find the distinct value (If Not (cat(j).Contains(ds.Tables(0).Rows(i).Item(j))) ... End If).

For i = 0 To 2
list(i) = New Integer(3) {}
For j = 0 To 2

[Code].....

View 2 Replies

Get Distinct Values From List(Of T) Using Linq?

Mar 10, 2012

I have a List(Of Hardware) - the List is called HWModels

Class Hardware has the following Properties:

ModelName
Status
CPUStatus
MemoryStatus
DiskStatus

The List is populated by reading a CSV file, once it's populated, I want to return the distinct records based on the ModelName

I've attempted by doing it as follows:

(From a In HWModels Select a.ModelName).Distinct

But this isn't right because I end up with a list of only the ModelName's and nothing else.

How do I get the Distinct function to return all of the other class members within the list?

View 1 Replies

Get Distinct Values In A Column Of Datagridview?

Mar 9, 2011

Like "SELECT DISTINCT(Col)" in sql query, how do we perform this in datagridview?[code]...

View 3 Replies

Use Linq For Select Distinct Values?

Mar 28, 2012

I'm pretty new in Linq and the first problem I've is to select the Distinct values from a ObservableCollection( Of T)

I've tried with[code]...

View 2 Replies

VS 2010 Sum Distinct Values Of Column

Apr 18, 2012

Im having trouble getting the sum of a "Status Column" It is unbound. It has 2 Items "Active and Inactive" I would like to have lblInact.Text to show the total of Inactives of that column.

View 20 Replies

C# - Selecting Multiple Distinct Values In Database?

Sep 27, 2010

I have this online quiz that generates random questions, but the only problem is that it repeats the previous questions. I have limited questions (I have 10 questions in my table, but I have limited the number of questions to be 5. The output would only display 5 random questions) which I named as RequiredRecords.

question_id
1
3
4

[code].....

I have tried to visit this question, but it doesn't resolve my problem. Below is some of my code and SQL statements I used.

I figured out that there's nothing wrong with my query on creating random questions and I can display it with no duplication, but there's something wrong with my other codes that makes the program having a duplication.

Code Behind using VS2008 3.5
Partial Class Student_DetailView
Inherits System.Web.UI.Page
Shared TotalRecords As Integer

[code].....

View 2 Replies

Dataview Distinct Values Not Sorted Correctly?

May 24, 2011

I am trying to do this:

Dim viewdata2 As DataView = fxts.fxtsdata.Tables("clients").DefaultView
Dim viewsorted2 As DataTable = viewdata2.ToTable("clients", True, "Surname", "Name")

[Code]....

View 1 Replies

Distinct Values In LINQ With Anonymous Types

Jul 2, 2011

Supposing the referenced List below contains 2 elements:
Dim Countries = From c In List _
Select New With { .Country = c.Country, .CountryID = c.CountryID }

The code above returns
.Country=Spain .CountryID = 1
.Country=Spain .CountryID = 1

How can I get the distinct values? The Countries query should contain only
.Country=Spain .CountryID = 1

View 5 Replies

Get Distinct Values And Converting Back Into DataTable?

Mar 14, 2012

I have a "result" which is DataTable and I like to get the x distinct values(City) and convert it back to DataTable how do I do this the code below gives me an error

Dim query = (From x In results.AsEnumerable()
Select (x.Field(Of String)("City"))).Distinct().CopyToDataTable()

so what I want is records of distinct cities I can get that but the problem I am having is converting it back to Datable.

Edited:I am using "where" in this statement and it does convert to Table(works fine) but not on "select"

Dim results = (From myRow In ds.Tables(1).AsEnumerable()
Where (myRow.Field(Of String)("xxxx") = xxxx)
Select myRow).Distinct().CopyToDataTable()

View 1 Replies

Get Row Count Of Distinct Values In A DataTable Column?

Mar 13, 2012

I have a DataTable that has several hundred rows.I want to get a row count of distinct values in a particular column.For example, I have a DataTable of Product Orders, but I want to get the number of unique Customers.

I was using this code, but I can't rely on it because my binding source is filtered from time to time.If my binding source has filtered out all rows datatable.DefaultView returns 0 rows.

View 5 Replies

Linq To DataTable Not Producing Distinct Values?

Oct 19, 2010

I have a datatable which has been dynamically generated from FoxPro tables using a UNION Select statement. e.g.SELECT * FROM x UNION SELECT * FROM y UNION SELECT * FROM Z ORDER By v_alue1This produces a datatable with about 100 rows, each containing many fields, one of which is c_olor. From this datatable, I would like to select the distinct colors and then output in a dropdown.I have a public class Color which just has one property which I can then use as the DataTextField and DataValueField for the dropdownlist

Public Class Color
Private _c_olor As String
Public Property c_olor() As String

[code].....

View 1 Replies

VS 2005 Filter A Combobox With Distinct Values

Dec 27, 2011

I have a combox and a datagridview on a form, the combox filters the datagridview but doesnt have Distinct values. I found this on one of your post. I have a Products DB Table with ProductID, Series, Description and UnitPrice, I am trying to filter the the datagrid using the column Series with the combobox but i get multiple values of the same thing in the combobox, where i would like to make it Distinct.[code]

View 6 Replies

VS 2010 Select Distinct Values From A DataTable?

Sep 28, 2010

Is it possible to select distinct values from a DataTable?

View 5 Replies

[VB 2010] How To DISTINCT Values When Have Multiple ComboBoxes

Dec 8, 2011

I f I have 1 combobox then my SQL query will be:

Dim objConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:DB.mdb;Jet OLEDB:Database Password=Pass1;")
Dim objdataadapter As New OleDbDataAdapter("SELECT DISTINCT LOCATION FROM Table", objConnection)

View 5 Replies

Distinct Values - If Sample Column Value Is The Same - Want All Comments Value To Be Concatenated

Jan 31, 2011

MY TABLE

sample comment1

sample comment2

[CODE]...

if sample column value is the same, i want all comments value to be concatenated

do while dr.read

listbox1.items.add(dr.getstring(0))

[CODE]...

View 2 Replies

Distinct.ToList Not Working With Null Values Present In List. Is There Another Way?

Nov 8, 2011

I load a list from a database like the example below. The class has more properties that the database table holds so when I load the list from the DB, there are Null values for certain properties of each item in the list. When I try List = List.Distinct.ToList, it never works (when null values are present).

[Code]...

View 7 Replies

C# - Generate All Columns With Double Quotes In Csv Export?

May 22, 2012

I generate csv content type export.

added columns like "A","B","C","D" by

columns = string.format("""{0}"",""{1}"",""{2}""","A","B","C")

stream.writeline(columns);

the csv file was exported but the first column don't having the double quotes. i need double quote with every column. i tried so many ways with in that one of the way is working fine that is columns = string.format(" ""{0}"",""{1}"",""{2}""","A","B","C") -- put space before first column.

but i need result without space.

Sample Code:

Public Class CSVExporter
Public Shared Sub WriteToCSV(personList As List(Of Person))
Dim attachment As String = "attachment; filename=PerosnList.csv"

[Code]....

View 1 Replies

Exclude Multiple Values In Sum Depending On Values In 2 Columns In SSRS 2005?

Apr 21, 2009

I have simple columns and their respective sums. However, I exclude 1 particular value from each sum, like so [code]...

Now I need to exclude another value ("Awaiting Progression") from a second column called "PROGRESSION".

Since I already exclude value based on 1 column called CATEGORY, how do I change my =Sum(Code.ExcludeOthers(Fields!CATEGORY.Value,Fields!ACTION_PLAN_NEW.Value)) to exclude a value from the PROGRESSION column if it's = ("Awaiting Progression") ?

i.e. How do I exclude multiple values, depending on values in 2 columns in SSRS 2005?

View 1 Replies

C# - Datagrid: Generate Columns From A Property Of The ItemsSource Collection

Nov 18, 2011

I'm trying to create a datagrid with auto generating columns. Let's say my Collection is a property named Articles of my viewmodel of type ObservableCollection<ArticleWrapper>.

I bind now the ItemsSource to this collection:

<wpf:DataGrid ItemsSource={Binding Articles} />

The class ArticleWrapper is like this:

[c#]
public class ArticleWrapper
{
public ArticleConfigurationSet ArticleConfigurationSet { get; set; }
public string Description { get; set; }

[Code]....

But now my problem: I want to bind the displayed data to my ArticleConfigurationSet property. But I cannot change my ItemsSource Binding, because the SelectedItem property of the datagrid must be of ArticleWrapper (for command handling).

The datagrid should also look like this:

View 3 Replies

Filter Out The Distinct Values From An Array To Another Array?

Jul 17, 2009

i have a requirement like i need to filter out the distinct values from an array to another array.

Dim str As String
For Each str In all
If (Not all2.contains(str)) Then
all2.Add(str)
End If
Next

i tried the above logic to get the distinct list but it is telling contains and Add are not the members of system.array?

View 2 Replies

Generate Random Double Values Between Range?

Dec 21, 2009

how do i generate random double values between range, for example:value between 2.50 to 3.50?

View 7 Replies







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