Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within C# and .NET
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Liutauras Vilda
Jeanne Boyarsky
paul wheaton
Sheriffs:
Ron McLeod
Devaka Cooray
Henry Wong
Saloon Keepers:
Tim Holloway
Stephan van Hulst
Carey Brown
Tim Moores
Mikalai Zaikin
Bartenders:
Frits Walraven
Forums:
C# and .NET
Other Application Frameworks
How to add a delete button in datalist/datatable (VB.NET)?
Dave Billy
Greenhorn
Posts: 2
posted 8 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I am making a website using vb .net
I have a datalist which has a datatable and delete button. the output llooks some thing like this below. 'X' is the delete button.
--------------------- | X name1 | X name3 | | X name2 | X name4 | ---------------------
When user click on the delete button(X) i want to get the id of that button and use that to delete a record in database.
<asp:DataList ID="DataList1" runat="server" RepeatColumns="3" RepeatLayout="Table" DataKeyField="ID" OnDeleteCommand="DataList1_DeleteCommand"> <ItemTemplate> <asp:ImageButton ID="imgdeletebtn" ImageUrl="x-icon.png" runat="server" /> <%# DataBinder.Eval(Container.DataItem, "StringValue") %> </ItemTemplate> </asp:DataList>
Protected Sub DataList1_DeleteCommand(ByVal source As Object, ByVal e As DataListCommandEventArgs) Dim getID As Integer = CInt(DataList1.DataKeys(CInt(e.Item.ItemIndex))) ErrorL.Text = getID Dim deletedQuery As String = "DELETE FROM [table_name] WHERE [ID] = '" & getID & "'" End Sub
i am new to VB .net and I cant seem to figure this out. I want to send the id in back end so i can delete that record.
Those who dance are thought mad by those who hear not the music. This tiny ad plays the bagpipes:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Convert VB.net to java
Sending a string from vb to java servlet
XML binding to <asp:dropdownlist> declaratively
Doubt in HashMap
OutOfMemory
More...