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
  1. Home
  2. Web Development
  3. ASP.NET
  4. Getting the selecteditem from gridview in ajax update panel

Getting the selecteditem from gridview in ajax update panel

Scheduled Pinned Locked Moved ASP.NET
helpdatabasedesignsysadminquestion
1 Posts 1 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.
  • F Offline
    F Offline
    Fu Manchu
    wrote on last edited by
    #1

    hi all, got a nasty one. Trying to get the selecteditem that a user clicks in an gridview, however the gridview is in an update panel. At first i thought the problem was with the session state - but what actually happens is the update panel does a postback sends everything back to the server but the server only sends back whats in the update panels. The main problem is when a user clicks the button, this causes an asynchronous postback the event fire in a different order to normal so i detected the button that was pressed after the page load event has fired and therefore miss capturing from session. Has anyone solved this? Here is my code: - Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim selectedItemID As Integer = CType(Session("SelectedItemID"), Integer) End Sub Protected Sub itemsGridView_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles itemsGridView.RowCommand Try Dim selectedItemID As Integer = CType(Session("SelectedItemID"), Integer) 'Check for custom CommandName Argument If e.CommandName = "SelectItem" Then ' Convert the row index stored in the CommandArgument ' property to an Integer. Dim index As Integer = Convert.ToInt32(e.CommandArgument) ' Retrieve the row that contains the ImageButton clicked ' by the user from the Rows collection. Dim row As GridViewRow = itemsGridView.Rows(index) ' Get a handle on ImageButton clicked Dim imgbtnItem As ImageButton imgbtnItem = row.Cells(13).Controls(0) selectedItemID = row.Cells(0).Text 'Session("SelectedItemID") = selectedItemID End If Catch ex As Exception MsgBox(ex.Message.ToString, MsgBoxStyle.Information, "ItemsGridView RowCommand Error!") End Try End Sub

    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