Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Hide Edit or Delete Buttons per Row in a GridView

Reply
Thread Tools

Hide Edit or Delete Buttons per Row in a GridView

 
 
Kevin Frey
Guest
Posts: n/a
 
      11-24-2006
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).


 
Reply With Quote
 
 
 
 
Onwuka Emeka
Guest
Posts: n/a
 
      11-24-2006
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" <(E-Mail Removed)> wrote in message
news:%23y%(E-Mail Removed)...
> 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).
>



 
Reply With Quote
 
 
 
 
Kevin Frey
Guest
Posts: n/a
 
      11-27-2006
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:%23y%(E-Mail Removed)...
>> 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).
>>

>
>



 
Reply With Quote
 
Kevin Frey
Guest
Posts: n/a
 
      11-27-2006
Never mind. These properties get set at DataBind time.

Thanks for the help.

"Kevin Frey" <(E-Mail Removed)> wrote in message
news:%23ZDiM$(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> 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" <(E-Mail Removed)> wrote in message
>> news:%23y%(E-Mail Removed)...
>>> 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).
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Icons for GridView Edit, Select, Update, Delete buttons? 11D.Universe ASP .Net Web Controls 1 06-12-2007 02:01 PM
CommandField that varies Edit/Delete button presence per row Kevin Frey ASP .Net 0 11-19-2006 11:07 PM
GridView nested in DataList - refreshing corresponding DataList row after updating GridView row H5N1 ASP .Net 0 04-26-2006 11:41 PM
GridView edit validation, edit dropdown list, delete popup confirm =?Utf-8?B?a2Vu?= ASP .Net 1 01-23-2006 12:51 PM
Q. About Show and Hide Edit and Delete Buttons Ather Ali Shaikh ASP .Net Datagrid Control 0 10-16-2003 06:26 AM



Advertisments