473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

DataList and delete

Hi all,

I created a DataList on a WebForm, and I want to have a separate delete
button at the bottom of the page. I can create a event handler for the
delete button and delete the selected item and re-bind the DataList.
That's working fine. But just curious, how can I tie the delete button
to the DeleteCommand of the DataList? I tried setting the delete
button CommandName property to "Delete", but it won't go to the
DataList DeleteCommand event handler. Does that mean to use the
DeleteCommand, it has to be defined within an ItemTemplate?

Thanks,
Harold

Nov 28 '05 #1
2 1479
Harold try posting what you are trying to do
Patrick

<ha*********@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Hi all,

I created a DataList on a WebForm, and I want to have a separate delete
button at the bottom of the page. I can create a event handler for the
delete button and delete the selected item and re-bind the DataList.
That's working fine. But just curious, how can I tie the delete button
to the DeleteCommand of the DataList? I tried setting the delete
button CommandName property to "Delete", but it won't go to the
DataList DeleteCommand event handler. Does that mean to use the
DeleteCommand, it has to be defined within an ItemTemplate?

Thanks,
Harold

Nov 29 '05 #2
Here's some relevant code:

Public Class TestDataList
Inherits System.Web.UI.Page

Protected WithEvents DataList1 As DataList
Protected WithEvents Button1 As Button

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Me.Page.IsPostBack Then
Dim arr As ArrayList
arr = New ArrayList
arr.Add("foo")
arr.Add("bar")
arr.Add("baz")
DataList1.DataSource = arr
DataList1.DataBind()
End If

Button1.CommandName = DataList1.DeleteCommandName
AddHandler DataList1.DeleteCommand, AddressOf
Me.DataList1_DeleteCommand
End Sub

Private Sub DataList1_DeleteCommand(ByVal sender As Object, ByVal e
As DataListCommandEventArgs)

End Sub

End Class
The button is defined outside the DataList (i.e., not in ItemTemplate
or EditItemTemplate). I want to be able to click the button and
trigger the DataList.DeleteCommand. The code above doesn't do it.

Nov 29 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chris Fink | last post by:
Hello, I have a datalist that contains an asp button. I have the need to pass a value that is bound to my datalist along the button when the on_click event is fired. My datalist creates a button...
3
by: Hardy Wang | last post by:
Hi all; I have a DataList with ItemCreated event like below: private void myList_ItemCreated(object sender , DataListItemEventArgs e) { DataRowView myRowView; DataRow myRow; if (e.Item.DataItem...
4
by: jenn | last post by:
Hi Anyone knows how to access to a value of a row in a datalist. Something like this in datagrid Dim str = MyDataGrid.Cell(0).tex I would like something like this Dim str =...
5
by: TCORDON | last post by:
I have a DataList with a bunch of items (eg. Shoppiong Cart) each Item has a Remove button, in the code Behind page I have a Sub called Remove Item which calls a Function like this: Public...
3
by: Verde | last post by:
Suppose I load a DataList up with a bunch of records from an underlying Database. The DataList shows an Edit and a Delete button. Each record in the database has a unique Integer ID value. Now,...
4
by: Nathan Sokalski | last post by:
I have a DataList that has an Button as one of the controls in it's ItemTemplate. The Button has a CommandName="delete" attribute, but when I click it the DeleteCommand event doesn't even get...
7
by: =?Utf-8?B?cGF0cmlja2RyZA==?= | last post by:
Hi all! I have a gridview inside a datagrid (nested) for which (gridview) the rowcommand is not raised in order to delete a row from the grid! I also tried OnRowCommand="method", didn't work...
0
by: pavankumar106 | last post by:
Hi im stuck in sm simple pb ..im having a datalist in wich im having images and each image have a delete button below it.now wen I press delete button I shud be able to delete that image in dataset...
3
by: Crazy Cat | last post by:
Hi all, I am developing an asp.net 2.0 application in Visual Studio 2005. On my page I have a simple datalist that is bound programmatically to a collection of simple objects. On this page I...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.