Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Please refer to the code. I can catch the button command in button1_Command. However, you need to attach the event handler - button1.Command += button1_Command;</p> <pre><code>&lt;asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" OnItemCommand="DetailsView1_ItemCommand" OnDataBound="DetailsView1_DataBound" AllowPaging="true"&gt; &lt;Fields&gt; &lt;asp:TemplateField&gt; &lt;ItemTemplate&gt; &lt;asp:Panel ID="Panel1" runat="server"&gt; &lt;/asp:Panel&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Fields&gt; &lt;/asp:DetailsView&gt; public class Customer { public int CustomerId { get; set; } public string FirstName { get; set; } public string LastName { get; set; } } private List&lt;Customer&gt; _customers; public List&lt;Customer&gt; Customers { get { if (_customers == null) { _customers = new List&lt;Customer&gt;(); _customers.Add(new Customer {CustomerId = 1, FirstName = "Jon", LastName = "Doe"}); _customers.Add(new Customer {CustomerId = 2, FirstName = "Mary", LastName = "Doe"}); _customers.Add(new Customer {CustomerId = 3, FirstName = "Brian", LastName = "Newton"}); } return _customers; } } protected void Page_Load(object sender, EventArgs e) { DetailsView1.DataSource = Customers; DetailsView1.DataBind(); } protected void DetailsView1_DataBound(object sender, EventArgs e) { Panel panel1 = DetailsView1.FindControl("Panel1") as Panel; Button button1 = new Button(); button1.Text = "Delete"; button1.Command += button1_Command; button1.CommandName = "Delete"; panel1.Controls.Add(button1); } void button1_Command(object sender, CommandEventArgs e) { // Delete data here } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload