fireing an event foo a button within a datalist

P

Paul Custance

Trying to get a button within a datalist to fire an event. However on
the coding I'm not sure how to link to the button within the datalist.

My data list is called dlorders and the button is called btnEdit and
carries a commandname edit. which then should fire code to open up 2
other buttons, cancel and update.

The label1.text is just test to see if code is firing which it aint!

public void dlOrders_Edit(object
Source,System.Web.UI.WebControls.DataListCommandEventArgs e)
{
//Turn on editing controls
dlOrders.EditItemIndex = e.Item.ItemIndex;
//Re-bind the data
sqlDataAdapter1.Fill(dsOrders1,"Orders");
DataBind();
Label1.Text = "Done";
}

have a created it right?

thanks

Paul Custance
 
S

Scott M.

Change the command name to EditCommand and the DataList's EditCommand event
handler will automatically fire.
 
P

Paul Custance

Thanks Scott but still no luck! I can get a buttone to fire the code
outside the DataList, but any buttons within the datalist just do not
work. I have tried changing the CommandName to "Edit" and "EditCommand"
but still nothing. In the Events they are all assigned to fire the
appropriate code, however something is not triggering!

I give up!

thanks

Paul
 
P

Paul Custance

Hey there,

I changed my buttons to linkbuttons and it seemingly works. So decided
to write the code from scratch again and now the buttons work! Many
thanks for all your support and help.

Paul Custance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top