Solved

Hiding an image button in a gridview

Posted on 2011-02-21
3
694 Views
Last Modified: 2012-05-11
hey all

I have a gridview table that are filled with a sql database. I also have a small image button of a pencil to signify "edit"

I would like to hide the edit button on some rows depedning on the value of the field

It is a time management system where users edit their overtime, if the status is "new" then they can edit, but if its "submitted" then I would like to hide the edit button but since its row dependant where can I do that?

<ItemTemplate>
                                <asp:ImageButton
                                    ID="ImageButton1"
                                    runat="server"
                                    CausesValidation="False"
                                    OnClick="editButton_Click"
                                    CommandArgument='<%# Eval("OvertimeID") %>'    
                                    SkinID="Edit"
                                    Text="Edit" />
                            </ItemTemplate>

Open in new window

0
Comment
Question by:samelamin
3 Comments
 
LVL 22

Expert Comment

by:pivar
ID: 34942534
Hi,

Have you tried something like:


Visible='<%# Eval("Status").ToString().Equals("new") %>'

/peter
0
 
LVL 13

Accepted Solution

by:
agarwalrahul earned 500 total points
ID: 34942545
you can put this code in gridview_rowdatboundevent:

 If e.Row.Cells(4).Text.Trim = "Condition" Then
                    ImageButton1.Visible = False
                End If
0
 

Author Closing Comment

by:samelamin
ID: 34942617
That worked thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question