Hi I was able to run my code with no problem once. Then I checked Paging on the GridView. Removing it didn't help. Can someone look at my code and tell me what I'm doing wrong? The error code is
DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'intTermID'.
Weird! Can you double check if the field intTermID exist or match with the DataField you assigned in your grid? Perhaps you have just misspelled it somewhere in your code.
I did double check, but it's not spelled wrong. I copied it from the database. Could this error have something to do with my Connection String. They moved to a new Dev server yesterday.
Im not exactly sure but typically this could mean that the field intTermID doesn't exist in your Select sql query. can you try creating a new gridview and bind it with the same query?
EDIT: I didn't see your last post. Glad you got it working ;)
hollyquinn
Member
194 Points
448 Posts
GridView with FormView error
Jan 31, 2013 07:19 PM|LINK
Hi I was able to run my code with no problem once. Then I checked Paging on the GridView. Removing it didn't help. Can someone look at my code and tell me what I'm doing wrong? The error code is
DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'intTermID'.
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:DoseRec_ProgramDocumentationConnectionString %>"
SelectCommand="SELECT [intTermID], [vcharTerms], [vcharTermsDefinition] FROM [tbl_Term]"
DeleteCommand="DELETE FROM tbl_Term WHERE (intTermID = @intTermID)"
InsertCommand="INSERT INTO tbl_TERM(vcharTerms, vcharTermsDefinition) VALUES (@vcharTerms, @vcharTermsDefinition)"
UpdateCommand="UPDATE tbl_term SET vcharTerms = @vcharTerms, vcharTermsDefinition = @vcharTermsDefinition WHERE (intTermID = @intTermID)"
ProviderName="System.Data.SqlClient">
<DeleteParameters>
<asp:Parameter Name="intTermID" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="vcharTerms" />
<asp:Parameter Name="vcharTermsDefinition" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="vcharTerms" />
<asp:Parameter Name="vcharTermsDefinition" />
<asp:Parameter Name="intTermID" />
</UpdateParameters>
</asp:SqlDataSource>
<br />
<br />
<asp:FormView ID="FormView1" runat="server" AllowPaging="True"
DataSourceID="SqlDataSource1" DefaultMode="Insert" DataKeyNames="intTermID">
<EditItemTemplate>
idField:
<asp:Label ID="idFieldLabel1" runat="server" Text='<%# Eval("intTermID") %>' />
<br />
field1:
<asp:TextBox ID="field1TextBox" runat="server" Text='<%# Bind("vcharTerms") %>' />
<br />
field2:
<asp:TextBox ID="field2TextBox" runat="server" Text='<%# Bind("vcharTermsDefinition") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True"
CommandName="Update" Text="Update" />
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<InsertItemTemplate>
field1:
<asp:TextBox ID="field1TextBox" runat="server" Text='<%# Bind("vcharTerms") %>' />
<br />
field2:
<asp:TextBox ID="field2TextBox" runat="server" Text='<%# Bind("vcharTermsDefinition") %>' />
<br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
CommandName="Insert" Text="Insert" />
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>
<ItemTemplate>
idField:
<asp:Label ID="idFieldLabel" runat="server" Text='<%# Eval("intTermID") %>' />
<br />
field1:
<asp:Label ID="field1Label" runat="server" Text='<%# Bind("vcharTerms") %>' />
<br />
field2:
<asp:Label ID="field2Label" runat="server" Text='<%# Bind("vcharTermsDefinition") %>' />
<br />
</ItemTemplate>
</asp:FormView>
<br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" DataKeyNames="intTermID">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="intTermID" HeaderText="intTermID" InsertVisible="False"
ReadOnly="True" SortExpression="intTermID" />
<asp:BoundField DataField="vcharTerms" HeaderText="vcharTerms"
SortExpression="vcharTermsDefinition" />
<asp:BoundField DataField="vcharTermsDefinition" HeaderText="vcharTermsDefinition"
SortExpression="vcharTermsDefinition" />
</Columns>
</asp:GridView>
http://www.hollyquinn.com/Blog
vinz
All-Star
127011 Points
17934 Posts
MVP
Re: GridView with FormView error
Feb 01, 2013 07:35 AM|LINK
Weird! Can you double check if the field intTermID exist or match with the DataField you assigned in your grid? Perhaps you have just misspelled it somewhere in your code.
MessageBox Controls for WebForms | Blog | Twitter | Linkedin
hollyquinn
Member
194 Points
448 Posts
Re: GridView with FormView error
Feb 01, 2013 12:13 PM|LINK
I did double check, but it's not spelled wrong. I copied it from the database. Could this error have something to do with my Connection String. They moved to a new Dev server yesterday.
http://www.hollyquinn.com/Blog
hollyquinn
Member
194 Points
448 Posts
Re: GridView with FormView error
Feb 01, 2013 01:02 PM|LINK
I figured it out. I had another GridView on the page that seemed to be causing the problems. Thanks.
http://www.hollyquinn.com/Blog
vinz
All-Star
127011 Points
17934 Posts
MVP
Re: GridView with FormView error
Feb 01, 2013 01:14 PM|LINK
Im not exactly sure but typically this could mean that the field intTermID doesn't exist in your Select sql query. can you try creating a new gridview and bind it with the same query?
EDIT: I didn't see your last post. Glad you got it working ;)
MessageBox Controls for WebForms | Blog | Twitter | Linkedin