473,758 Members | 4,381 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

LinqDataSource/ ListView - Inserts Returning No Values To Insert

I am attempting to insert a simple record with LinqDataSource from a
ListView, however I always get a message saying "....LinqDataSo urce
'dataSource' has no values to insert. Check that the 'values' dictionary
contains values...."

I am using a ListView with a DataSourceID of a LinqDataSource. When a new
row icon is clicked....the ListView properly enters into the
InsertItemTempl ate....however when the ImageButton with a CommandName of
"Update" is clicked....the above message is displayed. Data is properly
being bound, etc.

I have a simple project which reproduces the problem.

Please offer suggestions on what you think the problem is.

The C# source code is as follows...
using System;
using System.Collecti ons;
using System.Configur ation;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Secu rity;
using System.Web.UI;
using System.Web.UI.H tmlControls;
using System.Web.UI.W ebControls;
using System.Web.UI.W ebControls.WebP arts;
using System.Xml.Linq ;

public partial class Default : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{

}

protected void btnNewRow_Click (object sender, EventArgs e)
{
lvwList.EditInd ex = -1;
lvwList.InsertI temPosition = InsertItemPosit ion.FirstItem;
}
}

ASPX file is as follows....
<%@ Page Language="C#" AutoEventWireup ="true" CodeFile="Defau lt.aspx.cs"
Inherits="Defau lt" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>ListVi ew Insert Problem</title>
</head>
<body>
<form id="form1" runat="server">
<div style="margin-left: 100px; margin-top: 100px;">
<asp:ListView ID="lvwList"
DataSourceID="d ataSource"
DataKeyNames="A dvertiserCatego ry"
runat="server">
<LayoutTemplate >
<asp:ImageButto n ID="btnNewRow" runat="server"
CausesValidatio n="False"
OnClick="btnNew Row_Click"
ImageUrl="~/images/VSNet2008Action s/NewDocumentHS.p ng" />
<table runat="server"
cellspacing="0"
border="0">
<tr>
<th></th>
<th></th>
<th>Category</th>
<th>Description </th>
</tr>

<tr runat="server" id="itemPlaceho lder" />

</table>
</LayoutTemplate>
<ItemTemplate >
<tr>
<td align="center">
<asp:ImageButto n runat="server"
CausesValidatio n="False"
CommandName="Ed it"
ImageUrl="~/images/VSNet2008Action s/EditInformation HS.png" />
</td>
<td align="center">
<asp:ImageButto n runat="server"
OnClientClick=' showConfirm(thi s); return false;'
CausesValidatio n="False"
CommandName="De lete"
ImageUrl="~/images/VSNet2008Action s/DeleteHS.png" />
</td>
<td align="left">
<asp:Label runat="server" Text='<%# Eval("Advertise rCategory") %>' />
</td>
<td align="left">
<asp:Label runat="server" Text='<%# Eval("Advertise rCategoryDesc") %>'
/>
</td>
</tr>
</ItemTemplate>
<EditItemTempla te>
<tr>
<td colspan="2">
<asp:LinkButt on runat="server"
CausesValidatio n="True"
CommandName="Up date"
Text="Update"
style="margin-left: 2px;"
ToolTip="Click to Save Editing..."/>
<asp:LinkButt on runat="server"
CausesValidatio n="False"
CommandName="Ca ncel"
Text="Cancel"
style="margin-left: 5px; margin-right: 2px;"
ToolTip="Click to Cancel..." />
</td>
<td align="left">
<asp:Label ID="lblAdvertis erCategory" runat="server"
Text='<%# Bind("Advertise rCategory") %>' />
</td>
<td align="left">
<asp:TextBox ID="txtAdvertis erCategoryDesc" runat="server"
Text='<%# Bind("Advertise rCategoryDesc") %>'
Width="250px" />
</td>
</tr>
</EditItemTemplat e>
<InsertItemTemp late>
<tr runat="server">
<td colspan="2">
<asp:LinkButt on runat="server"
CausesValidatio n="True"
CommandName="In sert"
Text="Insert"
style="margin-left: 2px;"
ToolTip="Click to Insert New Item..."/>
<asp:LinkButt on runat="server"
CausesValidatio n="False"
CommandName="Ca ncel"
Text="Cancel"
style="margin-left: 5px; margin-right: 2px;"
ToolTip="Click to Cancel..." />
</td>
<td align="left">
<asp:TextBox ID="txtAdvertis erCategory" runat="server"
Text='<%# Bind("Advertise rCategory") %>'
Width="150px" />
</td>
<td align="left">
<asp:TextBox ID="txtAdvertis erCategoryDesc" runat="server"
Text='<%# Bind("Advertise rCategoryDesc") %>'
Width="250px" />
</td>
</tr>
</InsertItemTempl ate>
</asp:ListView>
<asp:LinqDataSo urce ID="dataSource " runat="server"
ContextTypeName ="SLCMS_DB_Data Context"
EnableDelete="T rue"
EnableInsert="T rue"
EnableUpdate="T rue"
TableName="SLCM S_AdvertiserCat egories">
</asp:LinqDataSou rce>
</div>
</form>
</body>
</html>

--
Philip
Jul 22 '08 #1
2 3363
I meant to say a CommandName of "Insert"... .not "Update"... . which is obvious
from the source code below.

Any help is greatly appreciated.... I have wasted many hours already.

--
Philip
"Philip" wrote:
I am attempting to insert a simple record with LinqDataSource from a
ListView, however I always get a message saying "....LinqDataSo urce
'dataSource' has no values to insert. Check that the 'values' dictionary
contains values...."

I am using a ListView with a DataSourceID of a LinqDataSource. When a new
row icon is clicked....the ListView properly enters into the
InsertItemTempl ate....however when the ImageButton with a CommandName of
"Update" is clicked....the above message is displayed. Data is properly
being bound, etc.

I have a simple project which reproduces the problem.

Please offer suggestions on what you think the problem is.

The C# source code is as follows...
using System;
using System.Collecti ons;
using System.Configur ation;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Secu rity;
using System.Web.UI;
using System.Web.UI.H tmlControls;
using System.Web.UI.W ebControls;
using System.Web.UI.W ebControls.WebP arts;
using System.Xml.Linq ;

public partial class Default : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{

}

protected void btnNewRow_Click (object sender, EventArgs e)
{
lvwList.EditInd ex = -1;
lvwList.InsertI temPosition = InsertItemPosit ion.FirstItem;
}
}

ASPX file is as follows....
<%@ Page Language="C#" AutoEventWireup ="true" CodeFile="Defau lt.aspx.cs"
Inherits="Defau lt" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>ListVi ew Insert Problem</title>
</head>
<body>
<form id="form1" runat="server">
<div style="margin-left: 100px; margin-top: 100px;">
<asp:ListView ID="lvwList"
DataSourceID="d ataSource"
DataKeyNames="A dvertiserCatego ry"
runat="server">
<LayoutTemplate >
<asp:ImageButto n ID="btnNewRow" runat="server"
CausesValidatio n="False"
OnClick="btnNew Row_Click"
ImageUrl="~/images/VSNet2008Action s/NewDocumentHS.p ng" />
<table runat="server"
cellspacing="0"
border="0">
<tr>
<th></th>
<th></th>
<th>Category</th>
<th>Description </th>
</tr>

<tr runat="server" id="itemPlaceho lder" />

</table>
</LayoutTemplate>
<ItemTemplate >
<tr>
<td align="center">
<asp:ImageButto n runat="server"
CausesValidatio n="False"
CommandName="Ed it"
ImageUrl="~/images/VSNet2008Action s/EditInformation HS.png" />
</td>
<td align="center">
<asp:ImageButto n runat="server"
OnClientClick=' showConfirm(thi s); return false;'
CausesValidatio n="False"
CommandName="De lete"
ImageUrl="~/images/VSNet2008Action s/DeleteHS.png" />
</td>
<td align="left">
<asp:Label runat="server" Text='<%# Eval("Advertise rCategory") %>' />
</td>
<td align="left">
<asp:Label runat="server" Text='<%# Eval("Advertise rCategoryDesc") %>'
/>
</td>
</tr>
</ItemTemplate>
<EditItemTempla te>
<tr>
<td colspan="2">
<asp:LinkButt on runat="server"
CausesValidatio n="True"
CommandName="Up date"
Text="Update"
style="margin-left: 2px;"
ToolTip="Click to Save Editing..."/>
<asp:LinkButt on runat="server"
CausesValidatio n="False"
CommandName="Ca ncel"
Text="Cancel"
style="margin-left: 5px; margin-right: 2px;"
ToolTip="Click to Cancel..." />
</td>
<td align="left">
<asp:Label ID="lblAdvertis erCategory" runat="server"
Text='<%# Bind("Advertise rCategory") %>' />
</td>
<td align="left">
<asp:TextBox ID="txtAdvertis erCategoryDesc" runat="server"
Text='<%# Bind("Advertise rCategoryDesc") %>'
Width="250px" />
</td>
</tr>
</EditItemTemplat e>
<InsertItemTemp late>
<tr runat="server">
<td colspan="2">
<asp:LinkButt on runat="server"
CausesValidatio n="True"
CommandName="In sert"
Text="Insert"
style="margin-left: 2px;"
ToolTip="Click to Insert New Item..."/>
<asp:LinkButt on runat="server"
CausesValidatio n="False"
CommandName="Ca ncel"
Text="Cancel"
style="margin-left: 5px; margin-right: 2px;"
ToolTip="Click to Cancel..." />
</td>
<td align="left">
<asp:TextBox ID="txtAdvertis erCategory" runat="server"
Text='<%# Bind("Advertise rCategory") %>'
Width="150px" />
</td>
<td align="left">
<asp:TextBox ID="txtAdvertis erCategoryDesc" runat="server"
Text='<%# Bind("Advertise rCategoryDesc") %>'
Width="250px" />
</td>
</tr>
</InsertItemTempl ate>
</asp:ListView>
<asp:LinqDataSo urce ID="dataSource " runat="server"
ContextTypeName ="SLCMS_DB_Data Context"
EnableDelete="T rue"
EnableInsert="T rue"
EnableUpdate="T rue"
TableName="SLCM S_AdvertiserCat egories">
</asp:LinqDataSou rce>
</div>
</form>
</body>
</html>

--
Philip
Jul 22 '08 #2
I have found the problem.

The runat="server" on the <tr tag ....1st statement within the
InsertItemTempl ate is causing the problem. Remove the runat="server" and
everything works fine.

Please shed some light on why this should cause a problem.

--
Philip
"Philip" wrote:
I meant to say a CommandName of "Insert"... .not "Update"... . which is obvious
from the source code below.

Any help is greatly appreciated.... I have wasted many hours already.

--
Philip
"Philip" wrote:
I am attempting to insert a simple record with LinqDataSource from a
ListView, however I always get a message saying "....LinqDataSo urce
'dataSource' has no values to insert. Check that the 'values' dictionary
contains values...."

I am using a ListView with a DataSourceID of a LinqDataSource. When a new
row icon is clicked....the ListView properly enters into the
InsertItemTempl ate....however when the ImageButton with a CommandName of
"Update" is clicked....the above message is displayed. Data is properly
being bound, etc.

I have a simple project which reproduces the problem.

Please offer suggestions on what you think the problem is.

The C# source code is as follows...
using System;
using System.Collecti ons;
using System.Configur ation;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Secu rity;
using System.Web.UI;
using System.Web.UI.H tmlControls;
using System.Web.UI.W ebControls;
using System.Web.UI.W ebControls.WebP arts;
using System.Xml.Linq ;

public partial class Default : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{

}

protected void btnNewRow_Click (object sender, EventArgs e)
{
lvwList.EditInd ex = -1;
lvwList.InsertI temPosition = InsertItemPosit ion.FirstItem;
}
}

ASPX file is as follows....
<%@ Page Language="C#" AutoEventWireup ="true" CodeFile="Defau lt.aspx.cs"
Inherits="Defau lt" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>ListVi ew Insert Problem</title>
</head>
<body>
<form id="form1" runat="server">
<div style="margin-left: 100px; margin-top: 100px;">
<asp:ListView ID="lvwList"
DataSourceID="d ataSource"
DataKeyNames="A dvertiserCatego ry"
runat="server">
<LayoutTemplate >
<asp:ImageButto n ID="btnNewRow" runat="server"
CausesValidatio n="False"
OnClick="btnNew Row_Click"
ImageUrl="~/images/VSNet2008Action s/NewDocumentHS.p ng" />
<table runat="server"
cellspacing="0"
border="0">
<tr>
<th></th>
<th></th>
<th>Category</th>
<th>Description </th>
</tr>

<tr runat="server" id="itemPlaceho lder" />

</table>
</LayoutTemplate>
<ItemTemplate >
<tr>
<td align="center">
<asp:ImageButto n runat="server"
CausesValidatio n="False"
CommandName="Ed it"
ImageUrl="~/images/VSNet2008Action s/EditInformation HS.png" />
</td>
<td align="center">
<asp:ImageButto n runat="server"
OnClientClick=' showConfirm(thi s); return false;'
CausesValidatio n="False"
CommandName="De lete"
ImageUrl="~/images/VSNet2008Action s/DeleteHS.png" />
</td>
<td align="left">
<asp:Label runat="server" Text='<%# Eval("Advertise rCategory") %>' />
</td>
<td align="left">
<asp:Label runat="server" Text='<%# Eval("Advertise rCategoryDesc") %>'
/>
</td>
</tr>
</ItemTemplate>
<EditItemTempla te>
<tr>
<td colspan="2">
<asp:LinkButt on runat="server"
CausesValidatio n="True"
CommandName="Up date"
Text="Update"
style="margin-left: 2px;"
ToolTip="Click to Save Editing..."/>
<asp:LinkButt on runat="server"
CausesValidatio n="False"
CommandName="Ca ncel"
Text="Cancel"
style="margin-left: 5px; margin-right: 2px;"
ToolTip="Click to Cancel..." />
</td>
<td align="left">
<asp:Label ID="lblAdvertis erCategory" runat="server"
Text='<%# Bind("Advertise rCategory") %>' />
</td>
<td align="left">
<asp:TextBox ID="txtAdvertis erCategoryDesc" runat="server"
Text='<%# Bind("Advertise rCategoryDesc") %>'
Width="250px" />
</td>
</tr>
</EditItemTemplat e>
<InsertItemTemp late>
<tr runat="server">
<td colspan="2">
<asp:LinkButt on runat="server"
CausesValidatio n="True"
CommandName="In sert"
Text="Insert"
style="margin-left: 2px;"
ToolTip="Click to Insert New Item..."/>
<asp:LinkButt on runat="server"
CausesValidatio n="False"
CommandName="Ca ncel"
Text="Cancel"
style="margin-left: 5px; margin-right: 2px;"
ToolTip="Click to Cancel..." />
</td>
<td align="left">
<asp:TextBox ID="txtAdvertis erCategory" runat="server"
Text='<%# Bind("Advertise rCategory") %>'
Width="150px" />
</td>
<td align="left">
<asp:TextBox ID="txtAdvertis erCategoryDesc" runat="server"
Text='<%# Bind("Advertise rCategoryDesc") %>'
Width="250px" />
</td>
</tr>
</InsertItemTempl ate>
</asp:ListView>
<asp:LinqDataSo urce ID="dataSource " runat="server"
ContextTypeName ="SLCMS_DB_Data Context"
EnableDelete="T rue"
EnableInsert="T rue"
EnableUpdate="T rue"
TableName="SLCM S_AdvertiserCat egories">
</asp:LinqDataSou rce>
</div>
</form>
</body>
</html>

--
Philip
Jul 23 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1886
by: Craig Stadler | last post by:
Using mysql 4.0.23- What is the best way to execute several (hundreds of) inserts and updates? Rather than issuing tons of individual inserts and updates, can I send the strings to a text file and then have mysql do them all?? IE : query.txt insert into table1 (col1,col2) values (1,2);
5
3582
by: Humble Geek | last post by:
Hi all. Quick and perhaps silly question, but... I am using Pg 7.3. I am writing a function using pgplsql. This function will perform multiple inserts. Let's say two of the inserts are as follows: -- id is primary key insert into users (id, username) values (nextval('someSeq'),'somename'); -- id is also a PK insert into log (id, uid, message) values (nextval('someOtherSeq'),XXX,'New
5
1748
by: Florence HENRY | last post by:
Hello, well, almost everything is in the subject ! I have to fill 2 tables (more complicated than in the example !): CREATE TABLE A ( id serial primary key, foo text);
3
3032
by: geoff | last post by:
I have a table called 'employee' with one column called 'name', a varchar. If I execute the following insert statements: insert into employee(name) values ('jones') insert into employee(name) values ('smith') insert into employee(name) values ('billy-bob') .. . . they work, no problem. If I execute the following: insert into employee(name) values ('jones'),('smith'),('billy-bob')
0
2136
by: =?Utf-8?B?UmFzbXVz?= | last post by:
I have a simple LiveView control that databinds to a LinqDataSource that maps to a table like this: CREATE TABLE MyTable (Id int NOT NULL, Name nvarchar(50) NULL, Picture image NULL) The OR mapper class (made in the VS 2008 designer) has a property of type System.Data.Linq.Binary
1
3913
by: shapper | last post by:
Hello, I have a ListView connected to a LinqDataSource. It uses a table, named Tags, with 2 fields: TagId and Text. I need to add a column named active. For this I created a LinqDataSource custom selecting: Private Sub ldsTags_Selecting(ByVal sender As Object, ByVal e As LinqDataSourceSelectEventArgs) Handles ldsTags.Selecting
0
2867
by: Marius Manolea | last post by:
Hi, I have a strange problem, I don't receive any modifications from listview in edit mode (OldValues & NewValues are empty) <asp:ListView ID="lvEditPersonRoles" runat="server" DataKeyNames="PersonId,RoleEntityGroup" DataSourceID="LDSPersonRoles"
0
1594
by: Andy B | last post by:
I have a GridView with a LINQDataSource attached to it. My code in the aspx markup is below. I need to know why only the checkbox field for the activated column is getting updated (the EditTemplate). None of the other columns get updated except for that one. Any ideas? The only column that is not able to be updated is the ID column, but that isn't even in the table. <asp:GridView ID="EternityNewsMemberList" runat="server"...
2
7039
by: mesut | last post by:
Hi colleagues, how can I configure a linqdatasource in code behind. I mean I would like to create the linqdatasource programmatically in the code behind rather then dropping from the toolbox. below is the way working but I dropped the linqdatasource control on the aspx page then configured. <asp:LinqDataSource ID="linqDSCostCenter" runat="server" ContextTypeName="Linq.ArtDBDataContext"
0
9492
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9908
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9740
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8744
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7287
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5332
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3832
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3402
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.