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

  • Home
  • SEARCH
  • 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 8051187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:14:55+00:00 2026-06-05T07:14:55+00:00

I’m having trouble getting a gridview’s button column to do anything. I’m using a

  • 0

I’m having trouble getting a gridview’s button column to do anything. I’m using a DirectoryInfo object to get the details of a file. I put the filename and the date created into the gridview columns. The third column is a button column. I have set the datakeys(Name, CreationTime), named the button column’s commandName to “sendcommand”. I want to send the filename to another page. I have this code for the RowCommand event:

protected void gvFiles_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
{

    if (e.CommandName == "sendcommand")
    {

        int index = Convert.ToInt32(e.CommandArgument);

        string fileID = ((GridView)sender).DataKeys[index]["Name"].ToString();
        Response.Redirect("irMain.aspx?@filename=" + fileID); 
    }
}

Nothing happens, except for a postback I think. How do I do this?

<asp:GridView ID="gvFiles" runat="server" Font-Name="Verdana" Font-Names="Verdana" 
        Width="401px" AutoGenerateColumns="False" BackColor="White" 
        BorderColor="Black" BorderStyle="Ridge" BorderWidth="2px" 
        DataKeyNames="Name,CreationTime" 
        >
        <Columns>
            <asp:HyperLinkField AccessibleHeaderText="File Name" 
                DataNavigateUrlFields="Name" DataNavigateUrlFormatString="~\Assets\reports\{0}" 
                DataTextField="Name" HeaderText="File Name" >

                <HeaderStyle BackColor="#0033CC" ForeColor="White" />
            </asp:HyperLinkField>
            <asp:BoundField AccessibleHeaderText="Date" DataField="CreationTime" 
                DataFormatString="{0:d}" HeaderText="Date">
                <HeaderStyle BackColor="Blue" ForeColor="White" />
            </asp:BoundField>

            <asp:ButtonField ButtonType="Button" Text="DO Stuff" CommandName="sendcommand" 
                HeaderText="WHAT?!" />

        </Columns>

        <AlternatingRowStyle BackColor="#6699FF" />

    </asp:GridView>
  • 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-05T07:14:56+00:00Added an answer on June 5, 2026 at 7:14 am

    You have to add the OnRowCommand attribute to your GridView in the ASPX, otherwise the GridView doesn’t know what method to call when you execute a command on it.

    AFAIK this is an entirely optional attribute and isn’t generated via the designer so you have to add it manually when you want to use it.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I am using parse_ini_file to read the contents of a file however it is
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported

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.