Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6163299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:48:11+00:00 2026-05-23T21:48:11+00:00

I have a gridview table that has three columns..fileID, uploadedBy and delete. Only the

  • 0

I have a gridview table that has three columns..fileID, uploadedBy and delete. Only the owner of the file can delete the file. How can I validate that the person deleting the file is the owner of the file. I have the login credentials and I have the uploadedBy string. I can get the login credentials but I cannot get the uploadedBy column from the delete link that is clicked.

<asp:TemplateField HeaderText="View" ItemStyle-HorizontalAlign="Center">
        <ItemTemplate>
          <asp:HyperLink ID="lnkView" runat="server" NavigateUrl='<%# Eval("Id", "~/ViewFile.aspx?Id={0}") %>' Text="View"></asp:HyperLink>
        </ItemTemplate>
      </asp:TemplateField>
      <asp:HyperLinkField ItemStyle-HorizontalAlign="Center" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="~/DeleteFile.aspx?Id={0}" HeaderText="Delete" Text="Delete" />

 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  {        
     switch (e.Row.RowType)
    {
      case DataControlRowType.DataRow:
        FileInfo myFileInfo = (FileInfo)e.Row.DataItem;
        switch (myFileInfo.ContentType.ToLower())
        {
          case "image/pjpeg":         // .jpg files
          case "image/gif":           // .gif files
          case "application/msword":  // .doc files
          case "text/plain":         // .txt files 
          case "application/vnd.ms-excel":  
            // Do nothing. When the row contains a viewable type, 
            // we want the View link to be enabled.
            break;
          default:
            // Find the View link and disable it.
            HyperLink myLink = (HyperLink)e.Row.FindControl("lnkView");
            myLink.Enabled = false;
            break;
        }
        break;
    }
  }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:48:13+00:00Added an answer on May 23, 2026 at 9:48 pm

    You can use the RowDataBound event and check UpdatedBy with the Current logined user. If it is not the same user, simply hide the delete button.

     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            System.Data.DataRow dr = ((System.Data.DataRowView)e.Row.DataItem).Row;
    
            if (dr["uploadedBy"].ToString() != HttpContext.Current.User.Identity.Name)
            {
                ((Button)e.Row.FindControl("btnDelete")).Visible = false;
            }
         }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a gridview (Edit and Delete enabled) that shows a table. A Text
I have a web user control, that has a table with 3 columns 1)
I have a pictures table that has the following columns: PICTURE_ID int IDENTITY(1000,1) NOT
I have an ASP.NET GridView which has columns that look like this: | Foo
I have a table that has Edit and Delete links in each row. I
I've got a gridview that renders as a table. I have an Add button
I have a GridView control in an Asp.net application, that has a <asp:buttonField> of
I have a GridView containing records from a table which can be deleted or
I have a database table that stores document information (DocID, Name, Type, Owner, etc).
Background I have a GridView that builds a table using an ObjectDataSource . This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.