Boundfield not returning count from LINQ query
I have a grouped LINQ query with a count summary line that I am binding to a gridview but the count field in the gridview just shows 'System.Data.DataRow'
What am I doing wrong here? Thanks!
<asp:BoundField DataField="Service_Name" HeaderText="Impacted services"/> <asp:BoundField DataField="Fieldname" HeaderText="Count"/>
Dim Services = From Lines In dtMain _ Where Lines.Field(Of String)("ULTIMATE_PARENT_NAME") = lstUPs.SelectedItem.ToString _ Group By Parent_Name = Lines.Field(Of String)("ULTIMATE_PARENT_NAME"), _ Service_Name = Lines.Field(Of String)("THIRD_PARTY_SERVICE_CLEAN") _ Into Fieldname = Group, Count() grdOuterGridView.DataSource = Services grdOuterGridView.DataBind()
I'm not an expert on that syntax (I use the extension methods) but it looks to me like Fieldname is being assigned the value Group, or the collection of rows that are being grouped on Parent_Name and Service_Name. Perhaps you need to define a field name for the result of Count()?
ETA: Got it. You should say Group.Count(), not Group, Count().