This is a migrated thread and some comments may be shown as answers.

Update db Only

1 Answer 33 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Ingrid Williams
Top achievements
Rank 1
Ingrid Williams asked on 26 Apr 2012, 07:02 PM
Is there a way to perform only an update to a database table (no insert or delete)  when listbox item is transferred from a souce radlistbox to a destination listbox.  Please supply some code in VB if possible.

Thank you

1 Answer, 1 is accepted

Sort by
0
Bozhidar
Telerik team
answered on 01 May 2012, 08:06 AM
Hi Ingrid,

The action which is performed on the database when you transfer an item is determined by the InsertCommand that you've set on the destination listbox's datasource (and DeleteCommand on the first one, if the transfer mode is set to move). So if you want to do an update, all you have to do is set an update query to these commands. Here's a small example:
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
    ConnectionString="<%$ ConnectionStrings:Area2ConnectionString %>"
    SelectCommand="SELECT * FROM [Areas]"
    InsertCommand="UPDATE [Areas] SET [update_user] = @update_user, [contactID] = @contactID WHERE [id] = @id">
    <InsertParameters>
        <asp:Parameter Name="id" Type="Int32" />
        <asp:Parameter Name="update_user" Type="String" />
        <asp:Parameter Name="contactID" Type="Int32" />
    </InsertParameters>
</asp:SqlDataSource>

If you want to learn more about the ListBox's automatic database update mechanism, you can refer to the following help article:
http://www.telerik.com/help/aspnet-ajax/listbox-automatic-database-updates.html 
 
All the best,
Bozhidar
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ListBox
Asked by
Ingrid Williams
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Share this question
or