Solved

Hiding an image button in a gridview

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

785 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