Solved

Hiding an image button in a gridview

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

863 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

25 Experts available now in Live!

Get 1:1 Help Now