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.