Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Can't hide GridView Delete button programmatically -- help!

Posted on 2010-08-24
4
Medium Priority
?
1,163 Views
Last Modified: 2012-05-10
We're using C#.
Need to hide Delete button on GridView programmatically when user has certain roles, etc.
Found this online and looks great but does not hide Delete button:

this.GridView1.AutoGenerateDeleteButton = false;

I"ve tried putting it in the Page_Load event handler and the GridView1_RowDataBound event handler.

I'd like to use this command as it seems very straigtforward.  Ideas?

Thx!
0
Comment
Question by:Eric3141
  • 2
4 Comments
 
LVL 4

Assisted Solution

by:udaydidigam
udaydidigam earned 600 total points
ID: 33510466
0
 
LVL 2

Author Comment

by:Eric3141
ID: 33510857
I tried this but it can't get it to work.  Ideas on what I'm doing wrong?

I looked at the article and now have this in my source view of aspx page:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="True"
            DataKeyNames="intCaseActionHistoryID" DataSourceID="odsCaseActionHistory"
            AutoGenerateDeleteButton="True">
            <Columns>...

The article did not say to do this but I changed AutoGenerateColumns="False" to "True".

Then in my page_load I have:

GridView1.AutoGenerateDeleteButton= false;
0
 
LVL 16

Accepted Solution

by:
burakiewicz earned 1400 total points
ID: 33515015
you could do something like this in the rowdatabound if that is not working
if (((LinkButton)e.Row.Cells[0].Controls[2]).Text.Equals("Delete", StringComparison.CurrentCultureIgnoreCase))
                        {
                            e.Row.Cells[0].Controls[2].Visible = false;
                        }
0
 
LVL 2

Author Comment

by:Eric3141
ID: 33527019
Uday:  I tried that and it works.  I prefer to do that sort of thing in the .cs page, though - just my preference.

Bura - I made the delete button a template field then did Find Control then set Visible = false;
Works great.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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.
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.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Loops Section Overview
Suggested Courses

773 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