List of all the comments along with the username ? Help

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 13 años
I am trying to display a gridview in which i want all the comments along with the blog title and username who posted that comment:

The only problem is in the username is it displaying the author of the blog who actually created the blog post but i want to display username who posted the comment.

This is what i am using:

<asp:GridView ID="GridView3" runat="server" DataSourceID="SqlDataSource3"
            AutoGenerateColumns="False">
            <Columns>
                <asp:BoundField DataField="CommentText" HeaderText="CommentText"
                    SortExpression="CommentText" />
                <asp:BoundField DataField="BlogPostTitle" HeaderText="BlogPostTitle"
                    SortExpression="BlogPostTitle" />
                <asp:BoundField DataField="Username" HeaderText="Username"
                    SortExpression="Username" />
            </Columns>
        </asp:GridView>

<asp:SqlDataSource ID="SqlDataSource3" runat="server"
        ConnectionString="Data Source=.\SQLEXPRESS;Initial Catalog=nop17;Integrated Security=True"
        ProviderName="System.Data.SqlClient"
        
            
            SelectCommand="SELECT Nop_BlogComment.CommentText, Nop_BlogPost.BlogPostTitle, Nop_Customer.Username FROM Nop_BlogComment INNER JOIN Nop_BlogPost ON Nop_BlogComment.BlogPostID = Nop_BlogPost.BlogPostID INNER JOIN Nop_Customer ON Nop_BlogPost.CreatedByID = Nop_Customer.CustomerID">
    </asp:SqlDataSource>
Hace 13 años
anyone ?
Hace 13 años
Finally, It's working !!!!!!

the problem was un-necessary i was using BlogPost Table and logically there is no use of using that table in the SQL Statement

i used this SQL statement

SELECT BlogComment.CommentText, BlogComment.CustomerID, Customer.Username FROM BlogComment INNER JOIN Customer ON BlogComment.CustomerID = Customer.CustomerID

and i am getting my desired output
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.