Solved

Hiding an image button in a gridview

Posted on 2011-02-21
3
691 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now