Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have Two table for rating:
Table 1:
id
Name
date
Files
Topic
Subject
article

Table 2 for rating:
id
Rate
This is my code:
XML
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" PageSize="4" AutoGenerateColumns="False"
        BackColor="White" BorderColor="#CCCCCC" BorderStyle="Ridge" BorderWidth="2px"
        CellPadding="3" DataKeyNames="ReplyDoubtID" DataSourceID="SqlDataSource1" OnRowCommand="GridView1_RowCommand"
        CssClass="roundedbox" CellSpacing="1" GridLines="None">
        <Columns>
            <asp:BoundField DataField="Name" HeaderText="Sender Name" SortExpression="Name" />
            <asp:BoundField DataField="Subject" HeaderText="Subject" SortExpression="Subject" />
            <asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" />
            <asp:TemplateField HeaderText="Topic">
                <ItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Topic") %>' TextMode="MultiLine"
                        Height="54px" Width="202px" CssClass="roundedbox"></asp:TextBox>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Solved Doubts">
                <ItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("ReplyDoubt") %>' TextMode="MultiLine"
                        Height="84px" Width="239px" CssClass="roundedbox"></asp:TextBox>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Download">
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CommandArgument='<%# Eval("Files") %>'
                        Text='<%# Eval("Files") %>' CommandName="Download" OnClick="LinkButton1_Click"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Rate">
                <ItemTemplate>
                    <cc1:Rating ID="Rating1" runat="server" StarCssClass="Star" WaitingStarCssClass="WaitingStar"
                        EmptyStarCssClass="Star" FilledStarCssClass="FilledStar" Height="22px" Width="107px"
                        AutoPostBack="True" OnChanged="OnRatingChanged" BehaviorID="Rating1_RatingExtender">
                    </cc1:Rating>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <FooterStyle BackColor="White" ForeColor="#000066" />
        <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
        <RowStyle ForeColor="#000066" />
        <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
        <SortedAscendingCellStyle BackColor="#F1F1F1" />
        <SortedAscendingHeaderStyle BackColor="#007DBB" />
        <SortedDescendingCellStyle BackColor="#CAC9C9" />
        <SortedDescendingHeaderStyle BackColor="#00547E" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:VCRConnectionString %>"
        SelectCommand="SELECT * FROM [ReplyDoubt]" FilterExpression="Topic LIKE '%{0}%'">
        <FilterParameters>
            <asp:ControlParameter Name="Topic" ControlID="TextBox3" PropertyName="Text" />
        </FilterParameters>
    </asp:SqlDataSource>
</asp:Content>


So i want to show the rating,but i have one sqldatasource connection please help me
is it possible......
Posted
Updated 29-Mar-15 6:28am
v2
Comments
Arkadeep De 29-Mar-15 13:16pm    
I will with Abinav's solution. Its look like that id is the foreign key between two tables. So its better to have join those table. If so then use joining.
Select Table1.Id, Table1.Name, Table1.date, Table1.Files, Table1.Topic,Table1.Subject, Table1.article, Table2.Rate from Table1 inner join Table2 on Table1.Id = Table2.Id
Manoj K Bhoir 30-Mar-15 1:12am    
Create New View in your database in which join those two tables and then bind that view to your Grid View.
Hanss1492 3-Jun-15 13:30pm    
is not clear to me, is this a master detail? I mean the second table have detail from the first one?
Or maybe is like Abhinav S. create a new view or procedure in SQL and bind into gridview

1 solution

Can you join the content of table 1 to table 2? If not, it may not make sense to show data for these two tables together.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900