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. 2.0 GridView selected row question...

2.0 GridView selected row question...

Scheduled Pinned Locked Moved ASP.NET
questiondatabasetestingbeta-testinghelp
2 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.
  • W Offline
    W Offline
    wbjohnson
    wrote on last edited by
    #1

    Hi all! Heres my problem - i have a gridview bound (via sqldatasource) to a simple table... The table consists of 2 columns, an ID column (auto increment primary key) and a NText column... On the webpage im displaying the gridview and a simple button. When the user clicks the button a new row is created and inserted... For testing purposes, the NText field just contains a random GUID. The gridview is then rebound and it appears in the list, great, that works fine..... however, when the user clicks the "add random" button i want the row they just created to be selected!!... so far i've got the ID of the last inserted using the Insert Indentity methodology and returning the ID field. The problem is dont seem to be able to set the SelectedKey or SelectedValue on the datagrid, all i can change is the index!! What am i missing here?? Cheers! Will

    K 1 Reply Last reply
    0
    • W wbjohnson

      Hi all! Heres my problem - i have a gridview bound (via sqldatasource) to a simple table... The table consists of 2 columns, an ID column (auto increment primary key) and a NText column... On the webpage im displaying the gridview and a simple button. When the user clicks the button a new row is created and inserted... For testing purposes, the NText field just contains a random GUID. The gridview is then rebound and it appears in the list, great, that works fine..... however, when the user clicks the "add random" button i want the row they just created to be selected!!... so far i've got the ID of the last inserted using the Insert Indentity methodology and returning the ID field. The problem is dont seem to be able to set the SelectedKey or SelectedValue on the datagrid, all i can change is the index!! What am i missing here?? Cheers! Will

      K Offline
      K Offline
      kubben
      wrote on last edited by
      #2

      Perhaps you should try using the selectedIndex property. Both of the SelectedDataKey and SelectedValue are readonly setting them will not affect which line is selected. Hope that helps. Ben

      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