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. selectedItem cells in dataGrid

selectedItem cells in dataGrid

Scheduled Pinned Locked Moved ASP.NET
questionhelp
2 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.
  • J Offline
    J Offline
    janetb99
    wrote on last edited by
    #1

    I'm making first, last, next, prev buttons outside of the datagrid. The labels/buttons that are assigned value/commands respectively based on which row of the datagrid is selected (which only needs to have dataBind on the first page load). Then, if the button outside the datagrid is pushed, I want it to go to the correct row of the datagrid and display a hidden cell of the datagrid in a label field. What is the correct syntax for pulling a datagrid's hidden column based on a button click outside of the datagrid? If you look at the code below, the correct row in the datagrid is highlighted when I push the next button, but I can't get the syntax right to have the lblPgTitle (outside the datagrid) display the hidden cell of the datagrid. (datagrid cell specifically is DataField="pgTitle") sub pgNext(sender as object, e as eventArgs) dim n as integer=cint(lblNext.text) dgNavList.selectedIndex=n lblPgTitle.text=dgNavList.item.cells(1).text end sub Tried another tack going through the onSelectedItemChanged in the datagrid withcoe below but get an error of identifer expected. Sub navNav(Sender as object, e as eventArgs) Dim itemTitle As TableCell = dgNavList.Items[dgNavList.SelectedIndex].Cells(1) lblPgTitle.text=convert.toString(itemTitle.text) End sub Any ideas? There's got to be a way to reference it. Janet

    J 1 Reply Last reply
    0
    • J janetb99

      I'm making first, last, next, prev buttons outside of the datagrid. The labels/buttons that are assigned value/commands respectively based on which row of the datagrid is selected (which only needs to have dataBind on the first page load). Then, if the button outside the datagrid is pushed, I want it to go to the correct row of the datagrid and display a hidden cell of the datagrid in a label field. What is the correct syntax for pulling a datagrid's hidden column based on a button click outside of the datagrid? If you look at the code below, the correct row in the datagrid is highlighted when I push the next button, but I can't get the syntax right to have the lblPgTitle (outside the datagrid) display the hidden cell of the datagrid. (datagrid cell specifically is DataField="pgTitle") sub pgNext(sender as object, e as eventArgs) dim n as integer=cint(lblNext.text) dgNavList.selectedIndex=n lblPgTitle.text=dgNavList.item.cells(1).text end sub Tried another tack going through the onSelectedItemChanged in the datagrid withcoe below but get an error of identifer expected. Sub navNav(Sender as object, e as eventArgs) Dim itemTitle As TableCell = dgNavList.Items[dgNavList.SelectedIndex].Cells(1) lblPgTitle.text=convert.toString(itemTitle.text) End sub Any ideas? There's got to be a way to reference it. Janet

      J Offline
      J Offline
      janetb99
      wrote on last edited by
      #2

      For anybody else out there, here's what worked - did not involve viewState and did not involve onSelectedIndexChanged by the event method of the button: sub pgNext(sender as object, e as eventArgs) dim n as integer=cint(lblNext.text) dgNavList.selectedIndex=n Dim itemTitle As TableCell = dgNavList.Items(n).Cells(1) lblPgTitle.text=convert.toString(itemTitle.text) 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