473,395 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Hide Edit or Delete Buttons per Row in a GridView

Hello. I asked this question a while back and got no response, so I thought
I'd have another shot.

When I display a list of records in a GridView, I want to be able to vary
the presence of the Edit and Delete buttons per row depending on eg. the
user's security permissions for that row, or attributes associated with the
record (eg. a purchase order that has been dispatched to a supplier cannot
be deleted).

Can anyone tell me the correct method to go about this?

The track I am currently taking is to build a specialised CommandField
object, and hiding the appropriate controls from within a data-binder. I'm
doing this so I don't have to reimplement much of CommandField
(InitializeCell specifically).

Is there any easier way to achieve this? (To be honest the whole
data-binding strategy seems very circuitous at times for cases like this).
Nov 24 '06 #1
3 14566
Im not very sure i get your problem clearly, but wouldn't doing something
like this solve your problem?
<asp:CommandField ShowDeleteButton="True"
Visible='<%#IsDeleteVisible(Eval("AProperty"))%>'> ' />

<asp:CommandField ShowEditButton="True"
Visible='<%#IsEditVisible(Eval("AProperty"))%>'/>

where IsDeleteVisible and IsEditVisible are functions that takes a value of
a property bound to your grid to determine if the button should show.


"Kevin Frey" <ke**********@hotmail.comwrote in message
news:%2******************@TK2MSFTNGP02.phx.gbl...
Hello. I asked this question a while back and got no response, so I
thought I'd have another shot.

When I display a list of records in a GridView, I want to be able to vary
the presence of the Edit and Delete buttons per row depending on eg. the
user's security permissions for that row, or attributes associated with
the
record (eg. a purchase order that has been dispatched to a supplier cannot
be deleted).

Can anyone tell me the correct method to go about this?

The track I am currently taking is to build a specialised CommandField
object, and hiding the appropriate controls from within a data-binder. I'm
doing this so I don't have to reimplement much of CommandField
(InitializeCell specifically).

Is there any easier way to achieve this? (To be honest the whole
data-binding strategy seems very circuitous at times for cases like this).

Nov 24 '06 #2
Yes, I guess that is pretty much a representation of what I am trying to
achieve.

Since I don't really use use declarative syntax for our circumstance,
however, when in the process of creating the control tree does this Eval get
evaluated?

(eg. at the time the cell is initialised or via a databinding operation?)

"Onwuka Emeka" <bu******@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Im not very sure i get your problem clearly, but wouldn't doing something
like this solve your problem?
<asp:CommandField ShowDeleteButton="True"
Visible='<%#IsDeleteVisible(Eval("AProperty"))%>'> ' />

<asp:CommandField ShowEditButton="True"
Visible='<%#IsEditVisible(Eval("AProperty"))%>'/>

where IsDeleteVisible and IsEditVisible are functions that takes a value
of a property bound to your grid to determine if the button should show.


"Kevin Frey" <ke**********@hotmail.comwrote in message
news:%2******************@TK2MSFTNGP02.phx.gbl...
>Hello. I asked this question a while back and got no response, so I
thought I'd have another shot.

When I display a list of records in a GridView, I want to be able to vary
the presence of the Edit and Delete buttons per row depending on eg. the
user's security permissions for that row, or attributes associated with
the
record (eg. a purchase order that has been dispatched to a supplier
cannot
be deleted).

Can anyone tell me the correct method to go about this?

The track I am currently taking is to build a specialised CommandField
object, and hiding the appropriate controls from within a data-binder.
I'm doing this so I don't have to reimplement much of CommandField
(InitializeCell specifically).

Is there any easier way to achieve this? (To be honest the whole
data-binding strategy seems very circuitous at times for cases like
this).


Nov 27 '06 #3
Never mind. These properties get set at DataBind time.

Thanks for the help.

"Kevin Frey" <ke**********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Yes, I guess that is pretty much a representation of what I am trying to
achieve.

Since I don't really use use declarative syntax for our circumstance,
however, when in the process of creating the control tree does this Eval
get evaluated?

(eg. at the time the cell is initialised or via a databinding operation?)

"Onwuka Emeka" <bu******@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>Im not very sure i get your problem clearly, but wouldn't doing something
like this solve your problem?
<asp:CommandField ShowDeleteButton="True"
Visible='<%#IsDeleteVisible(Eval("AProperty"))%>' >' />

<asp:CommandField ShowEditButton="True"
Visible='<%#IsEditVisible(Eval("AProperty"))%>'/>

where IsDeleteVisible and IsEditVisible are functions that takes a value
of a property bound to your grid to determine if the button should show.


"Kevin Frey" <ke**********@hotmail.comwrote in message
news:%2******************@TK2MSFTNGP02.phx.gbl. ..
>>Hello. I asked this question a while back and got no response, so I
thought I'd have another shot.

When I display a list of records in a GridView, I want to be able to
vary
the presence of the Edit and Delete buttons per row depending on eg. the
user's security permissions for that row, or attributes associated with
the
record (eg. a purchase order that has been dispatched to a supplier
cannot
be deleted).

Can anyone tell me the correct method to go about this?

The track I am currently taking is to build a specialised CommandField
object, and hiding the appropriate controls from within a data-binder.
I'm doing this so I don't have to reimplement much of CommandField
(InitializeCell specifically).

Is there any easier way to achieve this? (To be honest the whole
data-binding strategy seems very circuitous at times for cases like
this).



Nov 27 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: JC | last post by:
Hi, I am using a Datagrid and populating it from a database. I have a 'delete' button column, and when click it executes the DeleteCommand event. My problem is I would like this button to...
1
by: Qnavry | last post by:
I am creating one page to edit, delete, and add data to a database. The Add code works but the Edit and Delete do not. What am I doing wrong? If you need more code let me know. Thanks Code:...
12
by: dennist685 | last post by:
Can't edit, delete or add row in an Access database in a website 2003 When I implement a walkthrough using Northwind I have no trouble doing this. Also, in a windowsforms project I have no...
0
by: Kevin Frey | last post by:
When I display a list of records in a GridView, I want to be able to vary the presence of the Edit and Delete buttons per row depending on eg. the user's security permissions for that row, or...
1
by: Oded Dror | last post by:
Hi there, I'm using VWD 2005 Express and SQL Server 2005 Express When I have a table with Primary key ASP.NET let you add INSERT EDIT and DELETE button to the GridView But when you don't have...
3
by: Andy B | last post by:
I want to make an xslt file that formats and displays data from an XElement object through an xml control. I need to have the xslt file show edit/remove buttons next to each element/attribute that...
0
by: Andy B | last post by:
I want to make an xslt file that formats and displays data from an XElement object through an xml control. I need to have the xslt file show edit/remove buttons next to each element/attribute that...
1
by: coreyk | last post by:
I have been trying for ever to hide a column in gridview using the following code, GridView1.Columns.Visible = false; but the debugger says that index is out of range, the number columns when...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.