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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:46:35+00:00 2026-05-22T01:46:35+00:00

I got a question about the command behind a ButtonField (image type) in a

  • 0

I got a question about the command behind a ButtonField (image type) in a GridView.

Got a GridView called gvIngevuld in wich I show rows of data and 1 ButtonField row.
Now I have to put code behind these buttons (Each of them the same) to put some things in PDF format.
The problem is I don’t know how to put code behind these buttons ?
The code I have :

<asp:ButtonField ButtonType="Image" ImageUrl="~/Images/pdf.png"  CommandName="pdf_click" />

As you can see I used the CommandName=”pdf_click” property but when I click one of the buttons there’s only a postback but nothing happens.
Anyone who can help me out here ?

in case needed, code behind :

protected void pdf_click(object sender, EventArgs e)
{
    lblWelkom.Text = "Succes!";
}

Thanks.

  • 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-22T01:46:35+00:00Added an answer on May 22, 2026 at 1:46 am

    You should use RowCommand event of gridview. Set the commandArgument to your item’s unique key. (By default, it passes the row’s index)

    void gvIngevuld_RowCommand(Object sender, GridViewCommandEventArgs e)
     {
     // If multiple buttons are used in a GridView control, use the
     // CommandName property to determine which button was clicked.
     if(e.CommandName=="pdf_click")
      {
       // Convert the row index stored in the CommandArgument
       // property to an Integer.
       int index = Convert.ToInt32(e.CommandArgument);
    
       // Retrieve the row that contains the button clicked 
       // by the user from the Rows collection.
       GridViewRow row = gvIngevuld.Rows[index]; 
       //gbIngevuld is your GridView's name
    
       // Now you have access to the gridviewrow.
      }  
    }   
    

    Also, If you have set the DataKeyNames of the gridview, you can access it as follows:

        int index = Convert.ToInt32(e.CommandArgument);
        int ServerID = Convert.ToInt32(GridView1.DataKeys[index].Value);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got a question about event and bound command. What happens if I
using opengl 3.3, radeon 3870HD, c++.. I got question about interleaved arrays of data.
I asked about pipes in a previous question, got that working perfectly. However I
I asked a question a couple weeks ago about using setTimeout for a factorial
I'm a newbie and I'm trying to learn VBA and i got a question
This question is about the linux utility screen. I'd like to make a script
My question is, do JVM's share some kind of resource related to threading or
System information: I am running 64bit Ubuntu 10.10 on a 2 month old laptop.
I recently installed Helios on my windows 7 64 bit laptop and started seeing
I remember I used to write in a .bat call myprog.exe But dos says

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.