Adding buttons in a ButtonColumn in a DataGrid a row at a time

A

Adam White

I have a DataGrid and I have added a ButtonColumn that fires a
function on the row it corresponds to.

The problem I am having is I only want to display a button at the end
of a row if the "status" column in the row is set to "new". At the
moment there is a button at the end of every row.

Is there a way to do this?
 
S

Scott Allen

One way would be to catch the ItemDataBound event of the DataGrid.
Inside the event first check e.Item.ItemType to make sure you are
binding an Item or AlternatingItem (as opposed to a header or footer
item). If you have a real row, then check the status column and hide
the button (.Visible=false) if need be.

One way to locate the button is to use e.Item.FindControl("ButtonID")

HTH,
 

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

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top