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 8369205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:35:17+00:00 2026-06-09T13:35:17+00:00

I am having trouble accessing an asp.NET HiddenField from a Gridview ItemTemplate in the

  • 0

I am having trouble accessing an asp.NET HiddenField from a Gridview ItemTemplate in the codebehind. I need to be able to read the values that these hiddenfields contain so that I can execute the delete method.
The code is as follows

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="MemberList.ascx.cs" Inherits="UserControls_MemberList" %>
<asp:RadioButtonList ID="ReportSelect" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Value="1">All</asp:ListItem>
<asp:ListItem Value="2">Current Members</asp:ListItem>
<asp:ListItem Value="3">Perspective Members</asp:ListItem>
</asp:RadioButtonList>
<asp:Button ID="ReportSelectButton" runat="server" OnClick="ReportSelectButton_Click"
Text="Select Report Type" />
<asp:Button ID="LinkToHomePage" runat="server" Text="Back to Homepage" OnClick="LinkToHomePage_Click">
</asp:Button>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" Height="308px"
Width="1282px" onselectedindexchanged="GridView1_SelectedIndexChanged">
<Columns>
    <asp:BoundField HeaderText="First Name" AccessibleHeaderText="FirstName" DataField="FirstName">
    </asp:BoundField>
    <asp:BoundField HeaderText="Last Name" AccessibleHeaderText="LastName" DataField="LastName">
    </asp:BoundField>
    <asp:BoundField HeaderText="Street Address" AccessibleHeaderText="StreetAddress"
        DataField="StreetAddress"></asp:BoundField>
    <asp:BoundField HeaderText="City" AccessibleHeaderText="City" DataField="City"></asp:BoundField>
    <asp:BoundField HeaderText="State" AccessibleHeaderText="State" DataField="State">
    </asp:BoundField>
    <asp:BoundField HeaderText="Zip" AccessibleHeaderText="Zip" DataField="Zip"></asp:BoundField>
    <asp:BoundField HeaderText="Birthday" AccessibleHeaderText="Birthday" DataField="Birthday" />
    <asp:BoundField HeaderText="Email" AccessibleHeaderText="Email" DataField="Email">
    </asp:BoundField>
    <asp:BoundField HeaderText="PrimaryPhone" AccessibleHeaderText="PrimaryPhone" DataField="PrimaryPhone" />
    <asp:BoundField HeaderText="AlternatePhone" AccessibleHeaderText="AlternatePhone"
        DataField="AlternatePhone" />
    <asp:BoundField HeaderText="Pending" AccessibleHeaderText="Pending" DataField="Pending" />
    <asp:BoundField HeaderText="IsMember" AccessibleHeaderText="IsMember" DataField="IsMember" />
    <asp:BoundField HeaderText="Username" AccessibleHeaderText="Username" DataField="Username">
    </asp:BoundField>
    <asp:BoundField HeaderText="Description" AccessibleHeaderText="Descripton" DataField="Description" />
    <asp:TemplateField HeaderText="Edit" AccessibleHeaderText="Edit">
        <ItemTemplate>
            <asp:HyperLink ID="EditUsername" runat="server" NavigateUrl='<%# Link.ToMemberAdmin(Eval("Username").ToString())%>'
                Text="Edit" />
            <asp:Button ID="DeleteButton" runat="server" Text="Delete Entry" OnClick="DeleteButton_Click"/>
            <asp:HiddenField ID="HiddenUsername" Value='<%#Bind("Username") %>' runat="server" />
            <asp:HiddenField ID="HiddenEmail" Value='<%#Bind("Email") %>' runat="server" />
        </ItemTemplate>
    </asp:TemplateField>
</Columns>
</asp:GridView>

CodeBehind

protected void DeleteButton_Click(object sender, EventArgs e)
{
    HiddenField Username = GridView1.FindControl("HidderUsername") as HiddenField;
    HiddenField Email = GridView1.FindControl("HiddenEmail") as HiddenField;
    string username = Username.Value;
    string email = Email.Value;
    AdminAccess.DeleteMemberApplication(username, email);
}

Any help would be greatly appreciated.

  • 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-06-09T13:35:18+00:00Added an answer on June 9, 2026 at 1:35 pm

    The HiddenField controls are going to be part of a <td> which is one of the <tr> the GridView renders. The GridView control’s FindControl only knows of it’s immediate children and as the Hidden controls are two levels below that, it’s not going to find them. Instead, start from the sender and try to find its sibling Hidden controls. Replace the two HiddenControl lines in the event handler as below:

    HiddenField Username = (HiddenField) ((Button)sender).Parent.Controls.FindControl("HiddenUsername");
    HiddenField Email = (HiddenField) ((Button)sender).Parent.Controls.FindControl("HiddenEmail");
    

    And it should get the values you are looking for to delete the data in that row.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble accessing the id , area and theme values in my ViewData.
CakePHP Newbie :) I am having trouble accessing another controller and passing that data
I'm having trouble accessing springSecurityService from resources.groovy file, I'm trying to load user locale
I am having some trouble accessing a stateful session bean (SFSB) from an application
I am having trouble accessing the values in an array, the array looks like
I am having trouble accessing a Javascript function from my code behind file. I
I'm having trouble accessing a dataset. I've pulled data from an Access database (successfully
I am having trouble accessing Coda from command-line. I installed the command-line coda plug-in,
I am having trouble accessing the id from a hash: @categories = Category.includes(:discussions) The
I am having trouble accessing certain properties in an object that I receive as

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.