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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:28:16+00:00 2026-05-26T15:28:16+00:00

I’m having problems when using a ButtonField to issue a row command. When I

  • 0

I’m having problems when using a ButtonField to issue a row command.

When I click the ImageButton in the ButtonField, IsPostBack is false

My understanding is that an ImageButton in a ButtonField in a GridView should cause postback to be true.

Question: Can someone please explain whether I’m right or wrong and if there are properties to set on the button field to get it to issue a postback.

Some code:

Page_Load(object sender, EventArgs e) 
{
    if (!IsPostBack)
    {
        m_DataTable = GetDataTable();      
        Session["m_DataTable"] = m_DataTable;
    }
    else
    {
        m_DataTable = Session["m_DataTable"];
    }
}

and later in the code:

GridView1.Columns.Clear();

ButtonField cf = new ButtonField();
cf.HeaderStyle.CssClass = "comGridHeadCell";
cf.HeaderText = "some text";
cf.HeaderImageUrl = "images/something.png";
cf.Text = "action";
cf.CommandName = "action";
cf.ImageUrl = "images/something.png";
cf.ButtonType = ButtonType.Image;
cf.ItemStyle.CssClass = "comGridLink";

GridView1.Columns.Add(cf);

GridView1.DataSource = m_DataTable;
GridView1.DataBind();

also:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" AllowPaging="True" AllowSorting="True"  OnRowCommand="GridView_RowCommand" OnPageIndexChanging="GridView_PageIndexChanging">
  <PagerSettings PageButtonCount="25" />
</asp:GridView>

Edit:
I am running the site in debug mode via VS2010. I am testing using IE8.
If I use firefox, IsPostBack == true. This looks like a specific issue when debugging in IE8.

  • 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-26T15:28:16+00:00Added an answer on May 26, 2026 at 3:28 pm

    Are you creating that column on every load?

    The following fires off RowCommand as expected and IsPostBack is true as expected.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Diagnostics;
    using System.Data;
    
    namespace WebApplication2
    {
        public partial class _Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    Debugger.Break();
                }
                else
                {
                    Debugger.Break();
                }
    
                DataTable oDataTable = new DataTable();
                oDataTable.Columns.Add("animal");
                DataRow oDataRow = oDataTable.NewRow();
                oDataRow["animal"] = "cat";
                oDataTable.Rows.Add(oDataRow);
    
                GridView1.Columns.Clear();
    
                ButtonField cf = new ButtonField();
                cf.HeaderStyle.CssClass = "comGridHeadCell";
                cf.HeaderText = "some text";
                cf.HeaderImageUrl = "images/something.png";
                cf.Text = "action";
                cf.CommandName = "action";
                cf.ImageUrl = "images/something.png";
                cf.ButtonType = ButtonType.Image;
                cf.ItemStyle.CssClass = "comGridLink";
    
                GridView1.Columns.Add(cf);
    
                GridView1.DataSource = oDataTable;
                GridView1.DataBind();
            }
    
    
            protected void GridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
            {
    
            }
    
            protected void GridView_RowCommand(object sender, GridViewCommandEventArgs e)
            {
                Debugger.Break();
            }
        }
    }
    
    • 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
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm making a simple page using Google Maps API 3. My first. One marker
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.