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. DataGrid

DataGrid

Scheduled Pinned Locked Moved ASP.NET
help
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.
  • D Offline
    D Offline
    dennis joseph
    wrote on last edited by
    #1

    Hi all, i have placed a datagrid on the form and in that datagrid a dropdownlistbox is placed by property builder. I have to get the default value on each row to be highlighted. (Now am getting on each row in the same order as in the Table field when EDIT is clicked) Please help me in doing so Thanking you Dennis

    S 1 Reply Last reply
    0
    • D dennis joseph

      Hi all, i have placed a datagrid on the form and in that datagrid a dropdownlistbox is placed by property builder. I have to get the default value on each row to be highlighted. (Now am getting on each row in the same order as in the Table field when EDIT is clicked) Please help me in doing so Thanking you Dennis

      S Offline
      S Offline
      Scott Serl
      wrote on last edited by
      #2

      You have to write code in the DataGrids ItemDataBound event. In the event, you get a reference to the DropDownList using FindControl, get a reference to the DataRowView (the bound data for the row), and set the SelectedValue of the DropDownList to the value of the field you want in the DataRowView. In VB.Net:

              Dim drv As DataRowView
              Dim ddl As DropDownList
      
              'get the reference to the datarowview
              drv = DirectCast(e.Item.DataItem, DataRowView)
      
              'get the reference to the dropdownlist
              ddl = DirectCast(e.Item.Cells(ColumnIndex).FindControl("MyDropDownControl"), DropDownList)
      
              ddl.SelectedValue = drv("MyFieldName")
      

      I think that is what you are asking. If not, I'm sorry.

      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