Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > cannot delete or edit inserted records ( via detailsview) in gridview

Reply
Thread Tools

cannot delete or edit inserted records ( via detailsview) in gridview

 
 
Marc
Guest
Posts: n/a
 
      07-31-2006
Hi,

I made a detailsview for inserting records.
I also made a gridview for editing and deleting the same records.
The keyfield is an autonumbering field in Access (pcnr).

My problem is: I can see the new inserted records in the gridview but I
can't delete or edit them. When clicking on delete or edit link, nothing
happens (no error either). All the others records (not inserted via the
detailsview) can be edited and deleted.

Thanks for help
Marc

Here part of my code with the gridview:
---------------------------------------
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConflictDetection="CompareAllValues"
ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=C:\mydb"
DeleteCommand="DELETE FROM [pc] WHERE [pcnr] = ? AND [naam] = ? AND
[defect] = ? AND [type] = ? AND [software] = ? AND [lokaal] = ?"
InsertCommand="INSERT INTO [pc] ([pcnr], [naam], [defect], [type],
[software], [lokaal]) VALUES (?, ?, ?, ?, ?, ?)"
OldValuesParameterFormatString="original_{0}"
ProviderName="System.Data.OleDb"
SelectCommand="SELECT * FROM [pc]" UpdateCommand="UPDATE [pc] SET [naam]
= ?, [defect] = ?, [type] = ?, [software] = ?, [lokaal] = ? WHERE [pcnr] = ?
AND [naam] = ? AND [defect] = ? AND [type] = ? AND [software] = ? AND
[lokaal] = ?">
<DeleteParameters>
<asparameter Name="original_pcnr" Type="Int32" />
<asparameter Name="original_naam" Type="String" />
<asparameter Name="original_defect" Type="Boolean" />
<asparameter Name="original_type" Type="String" />
<asparameter Name="original_software" Type="String" />
<asparameter Name="original_lokaal" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asparameter Name="naam" Type="String" />
<asparameter Name="defect" Type="Boolean" />
<asparameter Name="type" Type="String" />
<asparameter Name="software" Type="String" />
<asparameter Name="lokaal" Type="String" />
<asparameter Name="original_pcnr" Type="Int32" />
<asparameter Name="original_naam" Type="String" />
<asparameter Name="original_defect" Type="Boolean" />
<asparameter Name="original_type" Type="String" />
<asparameter Name="original_software" Type="String" />
<asparameter Name="original_lokaal" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>

<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" PageSize="14" width="990px"
AutoGenerateColumns="False" CellPadding="4" DataKeyNames="pcnr"
DataSourceID="SqlDataSource1"
ForeColor="#333333" GridLines="None">
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lb1" runat="server"
OnClientClick="return confirm(yes?');"
CommandName="Delete">
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="pcnr" HeaderText="pcnr"
InsertVisible="False" ReadOnly="True"
SortExpression="pcnr" />
<asp:BoundField DataField="naam" HeaderText="naam"
SortExpression="naam" />
<asp:CheckBoxField DataField="defect" HeaderText="defect"
SortExpression="defect" />
<asp:BoundField DataField="type" HeaderText="type"
SortExpression="type" />
<asp:BoundField DataField="software" HeaderText="software"
SortExpression="software" />
<asp:BoundField DataField="lokaal" HeaderText="lokaal"
SortExpression="lokaal" />
</Columns>
</asp:GridView>




 
Reply With Quote
 
 
 
 
Marc
Guest
Posts: n/a
 
      07-31-2006
I found it.
All the fields must be filled ..


"Marc" <> schreef in bericht
news:%...
> Hi,
>
> I made a detailsview for inserting records.
> I also made a gridview for editing and deleting the same records.
> The keyfield is an autonumbering field in Access (pcnr).
>
> My problem is: I can see the new inserted records in the gridview but I
> can't delete or edit them. When clicking on delete or edit link, nothing
> happens (no error either). All the others records (not inserted via the
> detailsview) can be edited and deleted.
>
> Thanks for help
> Marc
>
> Here part of my code with the gridview:
> ---------------------------------------
> <asp:SqlDataSource ID="SqlDataSource1" runat="server"
> ConflictDetection="CompareAllValues"
> ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0 ;Data
> Source=C:\mydb"
> DeleteCommand="DELETE FROM [pc] WHERE [pcnr] = ? AND [naam] = ? AND
> [defect] = ? AND [type] = ? AND [software] = ? AND [lokaal] = ?"
> InsertCommand="INSERT INTO [pc] ([pcnr], [naam], [defect], [type],
> [software], [lokaal]) VALUES (?, ?, ?, ?, ?, ?)"
> OldValuesParameterFormatString="original_{0}"
> ProviderName="System.Data.OleDb"
> SelectCommand="SELECT * FROM [pc]" UpdateCommand="UPDATE [pc] SET [naam]
> = ?, [defect] = ?, [type] = ?, [software] = ?, [lokaal] = ? WHERE [pcnr] =
> ? AND [naam] = ? AND [defect] = ? AND [type] = ? AND [software] = ? AND
> [lokaal] = ?">
> <DeleteParameters>
> <asparameter Name="original_pcnr" Type="Int32" />
> <asparameter Name="original_naam" Type="String" />
> <asparameter Name="original_defect" Type="Boolean" />
> <asparameter Name="original_type" Type="String" />
> <asparameter Name="original_software" Type="String" />
> <asparameter Name="original_lokaal" Type="String" />
> </DeleteParameters>
> <UpdateParameters>
> <asparameter Name="naam" Type="String" />
> <asparameter Name="defect" Type="Boolean" />
> <asparameter Name="type" Type="String" />
> <asparameter Name="software" Type="String" />
> <asparameter Name="lokaal" Type="String" />
> <asparameter Name="original_pcnr" Type="Int32" />
> <asparameter Name="original_naam" Type="String" />
> <asparameter Name="original_defect" Type="Boolean" />
> <asparameter Name="original_type" Type="String" />
> <asparameter Name="original_software" Type="String" />
> <asparameter Name="original_lokaal" Type="String" />
> </UpdateParameters>
> </asp:SqlDataSource>
>
> <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
> AllowSorting="True" PageSize="14" width="990px"
> AutoGenerateColumns="False" CellPadding="4" DataKeyNames="pcnr"
> DataSourceID="SqlDataSource1"
> ForeColor="#333333" GridLines="None">
> <Columns>
> <asp:CommandField ShowEditButton="True" />
> <asp:TemplateField>
> <ItemTemplate>
> <asp:LinkButton ID="lb1" runat="server"
> OnClientClick="return confirm(yes?');"
> CommandName="Delete">
> </asp:LinkButton>
> </ItemTemplate>
> </asp:TemplateField>
> <asp:BoundField DataField="pcnr" HeaderText="pcnr"
> InsertVisible="False" ReadOnly="True"
> SortExpression="pcnr" />
> <asp:BoundField DataField="naam" HeaderText="naam"
> SortExpression="naam" />
> <asp:CheckBoxField DataField="defect" HeaderText="defect"
> SortExpression="defect" />
> <asp:BoundField DataField="type" HeaderText="type"
> SortExpression="type" />
> <asp:BoundField DataField="software" HeaderText="software"
> SortExpression="software" />
> <asp:BoundField DataField="lokaal" HeaderText="lokaal"
> SortExpression="lokaal" />
> </Columns>
> </asp:GridView>
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot delete or edit inserted records ( via detailsview) in gridview Marc ASP .Net Web Controls 1 07-31-2006 06:05 PM
GridView edit validation, edit dropdown list, delete popup confirm =?Utf-8?B?a2Vu?= ASP .Net 1 01-23-2006 12:51 PM
Snapshot restraint - edit, edit, edit Alan Browne Digital Photography 24 05-10-2005 10:15 PM
Delete records or update records Dan ASP General 1 05-10-2004 01:25 PM
New records in Datagrid to be inserted into SQL table. URGENT! =?Utf-8?B?U0s=?= ASP .Net 4 12-10-2003 03:11 PM



Advertisments