Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'PostId'.

$
0
0

 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="TopicId" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" Width="400px">
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            <Columns>
                <asp:BoundField DataField="TopicId" HeaderText="TopicId" InsertVisible="False" ReadOnly="True" SortExpression="TopicId" />
                <asp:BoundField DataField="TopicName" HeaderText="TopicName" SortExpression="TopicName" />
            <asp:TemplateField HeaderText="View Module" SortExpression="TopicId">
                     <ItemTemplate>
                           <a href="postmodule.aspx?eid=<%# Eval("TopicId") %>">View</a>
                     </ItemTemplate>
                 </asp:TemplateField>

            </Columns>
            <EditRowStyle BackColor="#999999" />
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#E9E7E2" />
            <SortedAscendingHeaderStyle BackColor="#506C8C" />
            <SortedDescendingCellStyle BackColor="#FFFDF8" />
            <SortedDescendingHeaderStyle BackColor="#6F8DAE" />

        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:portalConnectionString %>" SelectCommand="SELECT * FROM [Topics]"></asp:SqlDataSource>

above is my first page I can successfully redirect to postmodule page according to topicId but when again on the postmodule page I add this

<asp:TemplateField>
                    <ItemTemplate>
                        <a href="allques.aspx?eid=<%#Eval("PostId") %>">View</a>
                    </ItemTemplate>
                </asp:TemplateField>
to redirect on allques page I see nothing on postmodule page. If I don't add templatefield in postmodule page I don't get any error but if I add I get this error

DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'PostId'.
why is this happening?
Plz help!


Viewing all articles
Browse latest Browse all 8156