Hi there
I get the following error message while displaying a page

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

I have a FormView control which is bound to an sqldatasource

when it is loaded, it displays the above error msg

here is the formview ItemTemplate code

                                    <td align = "right"><b>Forum ID: </b></td>
                                    <td align = "left">
                                        <asp:TextBox ID = "txtForumID" runat = "server" Text = '<%# Eval("f.name") %>' ReadOnly = "true" />
                                    <td align = "right"><b>Topic ID: </b></td> 
                                    <td align = "left">
                                        <asp:TextBox ID = "txtTopicID" runat = "Server" Text = '<%# Eval("topicID") %>' ReadOnly = "true" />
                                    <td align = "right"><b>Topic Name: </b></td>
                                    <td align = "left">
                                        <asp:TextBox ID = "txtTopicName" runat = "server" Text = '<%# Eval("t.name") %>' ReadOnly = "true" />
                                    <td align = "right"><b>Descripttion: </b></td>
                                    <td align = "left">
                                        <asp:TextBox ID = "txtDescription" runat = "Server" Text = '<%# Eval("t.description") %>' ReadOnly = "true" />
                                        <br /><br />
                                        <asp:LinkButton ID = "lbtnEdit" runat = "server" Text = "Edit" CommandName = "Edit" />&nbsp;
                                        <asp:LinkButton ID = "lbtnDelete" runat = "server" Text = "Delete" CommandName = "Delete" />&nbsp;
                                        <asp:LinkButton ID = "lbtnNew" runat = "Server" Text = "New" CommandName = "New" />

the code of the datasource is as below

<asp:SqlDataSource ID = "FVDataSource" runat = "server" 
                            ConnectionString = "<%$ ConnectionStrings:ForumConnectionString %>"
                            SelectCommand = "SELECT f.forumID, f.name, t.topicID, t.name, t.description FROM tblTopics AS t 
                                             INNER JOIN tblForums AS f ON t.forumID = f.forumID 
                                             WHERE t.topicID = @topicID"
                            InsertCommand = "INSERT INTO [tblTopics] (forumID, name, description) VALUES (@forumID, @name, @description);
                                             SELECT @topicID = SCOPE_IDENTITY()"
                            UpdateCommand = "UPDATE [tblTopics] SET forumID = @forumID, name = @name, description = @description WHERE topicID = @topicID"
                            DeleteCommand = "DELETE [tblTopics] WHERE topicID = @topicID"
                            OnInserting = "FVDataSource_Inserting" OnDeleting = "FVDataSource_Deleting">
                   <asp:Parameter Name = "topicID" Type = "int32" DefaultValue = "0" />


Recommended Answers

All 2 Replies

instead of Eval("f.name")



You shouldn't need the table alias to select fields. If there are duplicate fields, like forumid, use a field alias, like "Select f.forumid as forumID_1, s.forumid as forumID_2.....".

thank you very much

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.