fireing an event foo a button within a datalist

  • Thread starter Thread starter Paul Custance
  • Start date Start date
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
 
Change the command name to EditCommand and the DataList's EditCommand event
handler will automatically fire.
 
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
 
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
 
Back
Top