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>