Re: Data Binding Issues

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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>



.



Relevant Pages

  • Data Binding Issues
    ... Explorer Error: ... Server Error in '/' Application ... An unhandled exception was generated during the execution of the ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Xilinx 3s8000?
    ... One exception, though: ... " Why can't Xilinx allow me to use the latest ISE to ... Backwards compatibility is a nightmare for any ... It's just that our software developer have their plate full with urgent ...
    (comp.arch.fpga)
  • Re: Accessing invisible control in Javascript
    ... Software Developer ... Microsoft MVP http://msmvps.com/blogs/egoldinhttp://usableasp.net ... then it will not have the client id and it will throw an exception. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Visual C-like exception from Delphi?
    ... AT> It it possible to raise VisualC-like exception from Delphi? ... Exception mechanisms are not compatible even between different C/C++ compilers. ... Illya Kysil, software developer ...
    (borland.public.delphi.nativeapi)