Link to home
Start Free TrialLog in
Avatar of rondre
rondreFlag for United States of America

asked on

Gridview SQLDatasource question

I have a directory page on a members only site and I'm using a gridview to display the information but i'm having a problem with the displayed data.  There are 3 tables involved iwth the query 1 table is the members table that pulls the members information, and the other 2 i want to do a count on the # of times the member id shows up in one specific column.  The problem is that the page is displaying both count columns within the gridview as the multiplication of the 2 counts.  I'm not sure how to get the individual parts to show up and hope someone can let me know where my sql is wrong.
<asp:GridView ID="GridView1" runat="server" DataSourceID="sdsMember" AutoGenerateColumns="false">
                                    <Columns>
                                    <asp:BoundField ItemStyle-Font-Bold="true" DataField="MEMBER_SNAME" HeaderText="Nickname" ItemStyle-Width="150px" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle" HeaderStyle-Width="150" HeaderStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Top" />
                                    <asp:ImageField DataImageUrlField="MEMBER_PIC" HeaderText="Avatar" ItemStyle-Width="150px" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Top"></asp:ImageField>
                                    <asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Top" ItemStyle-Width="150" HeaderStyle-Width="150">
                                    <HeaderTemplate># Shit Talk Posts</HeaderTemplate>
                                    <ItemTemplate><asp:Label ID="shitPosts" runat="server" Text='<%#Eval("NUMPOSTS") %>'></asp:Label></ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="RECORD" HeaderText="Record" HeaderStyle-Width="150" HeaderStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle" />
                                    <asp:BoundField DataField="TRADECOUNT" HeaderText="# of Acquisitions" HeaderStyle-Width="150" HeaderStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle" />
                                    </Columns>
                                </asp:GridView>
                                <asp:SqlDataSource ID="sdsMember" runat="server"
                                    ConnectionString="<%$ ConnectionStrings:DBSFL %>"  
                                    SelectCommand="SELECT M.MEMBER_SNAME, M.MEMBER_PIC, '(' + Convert(varchar,M.MEMBER_WINS) + '-' + Convert(varchar,M.MEMBER_LOSSES) + '-' + Convert(varchar,M.MEMBER_TIES) + ')' AS RECORD, COUNT(P.SHIT_ID) AS NUMPOSTS, COUNT(A.ACQ_ID) AS TRADECOUNT, M.MEMBER_POINTS FROM MEMBER M, ACQUISITIONS A, SHITTALK P WHERE M.MEMBER_ID = A.MEMBER_ID AND M.MEMBER_ID = P.POST_MEMBER GROUP BY MEMBER_SNAME, MEMBER_PIC, MEMBER_WINS, MEMBER_LOSSES, MEMBER_TIES, A.MEMBER_ID, MEMBER_POINTS"></asp:SqlDataSource>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of HugoHiasl
HugoHiasl

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rondre

ASKER

Thank you - i knew you could do the select statement within the select but wasn't sure how to link on the memberid field - worked great!