Register / Login
Win a copy of
Machine Learning with R: Expert techniques for predictive modeling
this week in the
Artificial Intelligence and Machine Learning
this forum made possible by our volunteer staff, including ...
Stephan van Hulst
C# and .NET
Other Application Frameworks
How to add a delete button in datalist/datatable (VB.NET)?
posted 3 years ago
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.
machines help you to do more, but experience less. Experience this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
Boost this thread!
Convert VB.net to java
Sending a string from vb to java servlet
XML binding to <asp:dropdownlist> declaratively
Doubt in HashMap