PC Review


Reply
Thread Tools Rating: Thread Rating: 2 votes, 1.00 average.

asp datalist delete and update

 
 
gigs
Guest
Posts: n/a
 
      22nd Feb 2008
in this code when i press delete or update button nothing happens. do i need to
put code in ondeletecommand="DataList1_DeleteCommand" and
onupdatecommand="DataList1_UpdateCommand" to delete or update particular row? in
gridview i didnt have to do anything




<aspataList ID="DataList1" runat="server" DataKeyField="CustomerID"
DataSourceID="SqlDataSource2" GridLines="Both"
RepeatDirection="Horizontal" oneditcommand="DataList1_EditCommand"
oncancelcommand="DataList1_CancelCommand"
onupdatecommand="DataList1_UpdateCommand">
<ItemTemplate>
<asp:Button runat="server" Text="Edit" Id="ItemEditButton"
CommandName="edit"/>
<asp:Button runat="server" Text="Delete" ID="ItemDeleteButton"
CommandName="delete" />
<br />
AddressID:
<asp:Label ID="AddressIDLabel" runat="server" Text='<%#
Eval("AddressID") %>' />
<br />
CustomerID:
<asp:Label ID="CustomerIDLabel" runat="server" Text='<%#
Eval("CustomerID") %>' />
<br />
Adress:
<asp:Label ID="AdressLabel" runat="server" Text='<%#
Eval("Adress") %>' />
<br />
Country:
<asp:Label ID="CountryLabel" runat="server" Text='<%#
Eval("Country") %>' />
<br />
<br />
</ItemTemplate>
<EditItemTemplate>
<asp:Button ID="ButtonEditUpdate" Text="Update"
CommandName="update" runat="server" />
<asp:Button ID="ButtonEditCancle" Text="Cancle"
CommandName="cancel" runat="server" />
<br />
AddressID:
<asp:TextBox ID="AddressIDTextBox" runat="server" Text='<%#
Eval("AddressID") %>' />
<br />
CustomerID:
<asp:TextBox ID="CustomerIDTextBox" runat="server" Text='<%#
Eval("CustomerID") %>' />
<br />
Adress:
<asp:TextBox ID="AdressTextBox" runat="server" Text='<%#
Eval("Adress") %>' />
<br />
Country:
<asp:TextBox ID="CountryTextBoxl" runat="server" Text='<%#
Eval("Country") %>' />
<br />
<br />
</EditItemTemplate>
</aspataList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:myDbConnectionString %>"
OldValuesParameterFormatString="original_{0}"

SelectCommand="SELECT * FROM [Adresses] WHERE ([CustomerID] =
@CustomerID)"
ConflictDetection="CompareAllValues"
DeleteCommand="DELETE FROM [Adresses] WHERE [CustomerID] =
@original_CustomerID AND [AddressID] = @original_AddressID AND [Adress] =
@original_Adress AND [Country] = @original_Country"
InsertCommand="INSERT INTO [Adresses] ([AddressID], [CustomerID],
[Adress], [Country]) VALUES (@AddressID, @CustomerID, @Adress, @Country)"
UpdateCommand="UPDATE [Adresses] SET [AddressID] = @AddressID,
[Adress] = @Adress, [Country] = @Country WHERE [CustomerID] =
@original_CustomerID AND [AddressID] = @original_AddressID AND [Adress] =
@original_Adress AND [Country] = @original_Country">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="CustomerID"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="original_CustomerID" Type="Int32" />
<asp:Parameter Name="original_AddressID" Type="Int32" />
<asp:Parameter Name="original_Adress" Type="String" />
<asp:Parameter Name="original_Country" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="AddressID" Type="Int32" />
<asp:Parameter Name="Adress" Type="String" />
<asp:Parameter Name="Country" Type="String" />
<asp:Parameter Name="original_CustomerID" Type="Int32" />
<asp:Parameter Name="original_AddressID" Type="Int32" />
<asp:Parameter Name="original_Adress" Type="String" />
<asp:Parameter Name="original_Country" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="AddressID" Type="Int32" />
<asp:Parameter Name="CustomerID" Type="Int32" />
<asp:Parameter Name="Adress" Type="String" />
<asp:Parameter Name="Country" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
DataList and delete haroldsphsu@gmail.com Microsoft ASP .NET 2 29th Nov 2005 05:55 PM
datalist not resfreshing after update branton ellerbee Microsoft ASP .NET 1 30th Dec 2004 12:16 AM
Setting up a datalist control - Item_DataBound for a datalist in a datalist Nevyn Twyll Microsoft ASP .NET 8 9th Sep 2004 11:13 PM
Datalist- Update Query =?Utf-8?B?dmptZWhyYQ==?= Microsoft Dot NET 0 18th Aug 2004 03:17 AM
Datalist: update a datasource without using select/edit/update Hartmut Schroth Microsoft ASP .NET 3 1st Dec 2003 09:54 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:17 AM.