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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:41:06+00:00 2026-06-06T20:41:06+00:00

I am having trouble when trying to fire a button in a GridView with

  • 0

I am having trouble when trying to fire a button in a GridView with the parameter CommandName = “x”, I try to reach my “If” in the GridView1_RowCommand event but I just cant for some reason, if you could help me I’d be gratefull .

This is my .aspx part

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
 <ContentTemplate>
    <asp:GridView ID="GridView1" runat="server" CellPadding="4" 
            EnableModelValidation="True" ForeColor="#333333" GridLines="None" 
            Height="193px" Width="968px" AllowPaging="True" AllowSorting="True" 
            AutoGenerateColumns="False" DataKeyNames="ID" 
            DataSourceID="SOURCE1" onrowcommand="GridView1_RowCommand">
            <AlternatingRowStyle BackColor="White" />
            <Columns>
            <asp:TemplateField ShowHeader="False">
                <ItemTemplate>
                    <asp:Button Text = "Seleccionar" runat="server" CommandName="X" CommandArgument='<%# Container.DataItemIndex %>' />
                </ItemTemplate>
            </asp:TemplateField>
                <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" 
                    ReadOnly="True" SortExpression="ID" />
                <asp:BoundField DataField="IDEmpresa" HeaderText="IDEmpresa" 
                    SortExpression="IDEmpresa" />
            </Columns>
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        </asp:GridView> 
   </ContentTemplate>
</asp:UpdatePanel>

And this is my C# code:

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "X")
    {
        int index = Convert.ToInt32(e.CommandArgument);
        GridViewRow row = GridView1.Rows[index];
        Label1.Text = "WOW It reached out";
    }
}

I followed the instructions of the ASP.net page, and im fairly new to .net (I dont know if the UpdatePanel has something to do with it)

  • 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-06T20:41:08+00:00Added an answer on June 6, 2026 at 8:41 pm

    Doing a quick test, the code you have provided works, but I did have to wire up my own datasource.

    What you are missing here is that Label1 is outside of your UpdatePanel and will not refresh based on your localized postback within the UpdatePanel.

    A word of caution with GridViews and UpdatePanels/Buttons. Make sure you are not manually binding/rebinding during Page_Load, and if you have code to do so, you do so within an if(!IsPostBack) { } statement.

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

Sidebar

Related Questions

I am having trouble trying to get a click event to fire after the
I am having trouble trying to trigger a submit button in firefox 3.6 but
I'm having trouble getting DownloadProgressChangedEventHandler to fire. I understand that, worst case, the event
This query works fine but I'm having trouble trying to figure out why it
I'm trying the NES 0.3 (https://github.com/elliotritchie/NES) but are having some trouble understanding what happens.
I`m having trouble trying to optimize this query with OVER (PARTITION BY ...) because
i'm having trouble trying to define this function-like macro, which takes 4 vector magnitudes
I am having trouble trying to print a table from a webpage. When I
I'm having trouble trying to use a function in a javascript file I've included
I am really having trouble trying to figure out how to find certain records

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.