1

I have Asp.net application that implemented with Dynamic Data technology. All data from my database is displayed in DetailsView (standard for dynamic data). Each row in DetailsView contains icon with buttons edit and delete. In some cases I should disable row editing and hide edit-delete buttons in some rows. Is it possible in dynamics.

P.S. I have found DetailsView.AutoGenerateEditButton property, but it does not applicable for me: the property just hide edit-delete button for all grid, not for some rows.

animuson
  • 53,861
  • 28
  • 137
  • 147
digor_ua
  • 572
  • 2
  • 7
  • 20

2 Answers2

2

You can use RowDataBound event.

Have a look at this article about Custom Formatting Based Upon Data

huMpty duMpty
  • 14,346
  • 14
  • 60
  • 99
0

Markup:

<asp:LinkButton runat="server" CommandName="Edit" Visible='<%# DecideHere((int)Eval("ID")) %>' Text="Edit" />

Code-behind:

protected bool DecideHere(int id)
{
    return id % 2 == 0;
}

(this works for me in GridView, and I'm sure something similar will work for you in DetailsView)

abatishchev
  • 98,240
  • 88
  • 296
  • 433