Re: Data Binding Issues
- From: "Eliyahu Goldin" <REMOVEALLCAPITALSeEgGoldDinN@xxxxxxxxxxxx>
- Date: Thu, 19 Jul 2007 11:54:32 +0300
This attribute
DataKeyNames="Id"
refers to column "Id" in your data source. You don't seem to have this
column. If it is the case, just remove this attribute.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Swagener" <riqband@xxxxxxxxx> wrote in message
news:1184831729.616576.268640@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi all, I can't seem to get rid of this error whatever I do to have a
successful connection:
``````````````````````````````````````````````````````````````````````````````````
Explorer Error:
Server Error in '/' Application
DataBinding: 'System.Data.Common.DbDataRecord' does not contain a
property with the name 'Id'.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace
below.
````````````````````````````````````````````````````````````````````````
Aspx File:
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource
ID="SqlDataSource1"
runat="server"
DataSourceMode="DataReader"
ConnectionString="<%$ ConnectionStrings:Surveyslol %>"
SelectCommand="SELECT DvName, DvcodeNo FROM DivisionName">
</asp:SqlDataSource>
<asp:GridView
ID="GridView1"
runat="server"
AutoGenerateColumns="True"
DataKeyNames="Id"
DataSourceID="SqlDataSource1">
</asp:GridView>
</div>
</form>
</body>
</html>
```````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````
Web.Config:
<?xml version="1.0"?>
<configuration>
<appSettings/>
<connectionStrings>
<add name="Surveyslol" connectionString="Data Source=.
\SQLSERVER;Initial Catalog=Surveys;Integrated Security=SSPI;"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true"/>
<authentication mode="Forms"/>
</system.web>
</configuration>
.
- References:
- Data Binding Issues
- From: Swagener
- Data Binding Issues
- Prev by Date: Re: Getting event/method name
- Next by Date: Two buttons on same page
- Previous by thread: Data Binding Issues
- Next by thread: Custom Software Development
- Index(es):
Relevant Pages
|