Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. GridView ButtonField Image vs Button and RowCommand

GridView ButtonField Image vs Button and RowCommand

Scheduled Pinned Locked Moved ASP.NET
visual-studiosysadmin
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    binarymax
    wrote on last edited by
    #1

    I thought I would post this because it was driving me nuts. When you are firing a RowCommand from a GridView ButtonField when the ButtonField is of type Image, Page.IsPostBack is false Button column as image:

    <asp:GridView ID="gvMyGrid" runat="server" AutoGenerateColumns="false" Width="200px" >
    ...
    <asp:ButtonField CommandName="Up" ButtonType="Image" ImageUrl="Images/up.gif" />
    </Columns>

    When you are firing a RowCommand from a GridView ButtonField when the ButtonField is of type Button, Page.IsPostBack is true Button column as button:

    <asp:GridView ID="gvMyGrid" runat="server" AutoGenerateColumns="false" Width="200px" >
    ...
    <asp:ButtonField CommandName="Up" ButtonType="Button" Text="Up" />
    </Columns>

    Code Behind:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Not Page.IsPostBack Then
    'This code will be reached on first load and also when the user clicks a Gridview ButtonField Image!!!
    End If
    End Sub

    Protected Sub gvMyGrid_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs) Handles gvMyGrid.RowCommand
    ...
    End Sub

    M 1 Reply Last reply
    0
    • B binarymax

      I thought I would post this because it was driving me nuts. When you are firing a RowCommand from a GridView ButtonField when the ButtonField is of type Image, Page.IsPostBack is false Button column as image:

      <asp:GridView ID="gvMyGrid" runat="server" AutoGenerateColumns="false" Width="200px" >
      ...
      <asp:ButtonField CommandName="Up" ButtonType="Image" ImageUrl="Images/up.gif" />
      </Columns>

      When you are firing a RowCommand from a GridView ButtonField when the ButtonField is of type Button, Page.IsPostBack is true Button column as button:

      <asp:GridView ID="gvMyGrid" runat="server" AutoGenerateColumns="false" Width="200px" >
      ...
      <asp:ButtonField CommandName="Up" ButtonType="Button" Text="Up" />
      </Columns>

      Code Behind:

      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      If Not Page.IsPostBack Then
      'This code will be reached on first load and also when the user clicks a Gridview ButtonField Image!!!
      End If
      End Sub

      Protected Sub gvMyGrid_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs) Handles gvMyGrid.RowCommand
      ...
      End Sub

      M Offline
      M Offline
      Member 3879881
      wrote on last edited by
      #2

      what ur trying to ask quest is not fully completed

      Thanks & Regards, Member 3879881, please don't forget to vote on the post

      B 1 Reply Last reply
      0
      • M Member 3879881

        what ur trying to ask quest is not fully completed

        Thanks & Regards, Member 3879881, please don't forget to vote on the post

        B Offline
        B Offline
        binarymax
        wrote on last edited by
        #3

        It is not a question :) Its just some information that I thought would be useful since I think it is a bug with the .NET framework.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups