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. dynamic dropdownlist in datagrid

dynamic dropdownlist in datagrid

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

    i have three column s as dropdownlists in datagrid. i want to populate the second and third dd on the onseleection changed event of first dropdownlist of datagrid. hoe to implement this at the runtime. please help me out neo

    E 1 Reply Last reply
    0
    • N neoms21

      i have three column s as dropdownlists in datagrid. i want to populate the second and third dd on the onseleection changed event of first dropdownlist of datagrid. hoe to implement this at the runtime. please help me out neo

      E Offline
      E Offline
      emorales
      wrote on last edited by
      #2

      Hi, Do the following, 1. Change autopostback to the first dd 2. On the First dd write in the aspx code 3. Write in the behind code Public Sub Dropdownlist1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) End Sub To access to the others dd you will need the item id and the column where those are located. You can do the following= I. In the Itemdatabound save the item index in the Dropdownlist1: ctype(me.datagrid.items(1).cells(ddColumn).findcontrol("Dropdownlist1"),dropdownlist).Attributes.add("itemindex",e.itemindex) II. In the Dropdownlist1_SelectedIndexChanged: ItIndex as integer = ctype(me.datagrid.items(1).cells(ddColumn).findcontrol("Dropdownlist1"),dropdownlist).Attributes("itemindex") ctype(me.datagrid.items(ItIndex ).cells(intddColumn).findcontrol("dd2"),dropdownlist).datasource = YourDataSource ctype(me.datagrid.items(ItIndex ).cells(intddColumn).findcontrol("dd2"),dropdownlist).databind Happy Programming emorales mcdba, mcad, mcsd

      N 1 Reply Last reply
      0
      • E emorales

        Hi, Do the following, 1. Change autopostback to the first dd 2. On the First dd write in the aspx code 3. Write in the behind code Public Sub Dropdownlist1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) End Sub To access to the others dd you will need the item id and the column where those are located. You can do the following= I. In the Itemdatabound save the item index in the Dropdownlist1: ctype(me.datagrid.items(1).cells(ddColumn).findcontrol("Dropdownlist1"),dropdownlist).Attributes.add("itemindex",e.itemindex) II. In the Dropdownlist1_SelectedIndexChanged: ItIndex as integer = ctype(me.datagrid.items(1).cells(ddColumn).findcontrol("Dropdownlist1"),dropdownlist).Attributes("itemindex") ctype(me.datagrid.items(ItIndex ).cells(intddColumn).findcontrol("dd2"),dropdownlist).datasource = YourDataSource ctype(me.datagrid.items(ItIndex ).cells(intddColumn).findcontrol("dd2"),dropdownlist).databind Happy Programming emorales mcdba, mcad, mcsd

        N Offline
        N Offline
        neoms21
        wrote on last edited by
        #3

        thanks a lot emorales thts did the trick:)

        E 1 Reply Last reply
        0
        • N neoms21

          thanks a lot emorales thts did the trick:)

          E Offline
          E Offline
          emorales
          wrote on last edited by
          #4

          Hi, I found an error in the example: I. In the Itemdatabound save the item index in the Dropdownlist1: ctype(me.datagrid.items(e.itemindex).cells(ddColumn).findcontrol("Dropdownlist1"),dropdownlist).Attributes.add("itemindex",e.itemindex) II. In the Dropdownlist1_SelectedIndexChanged: ItIndex as integer = ctype(sender,dropdownlist).Attributes("itemindex") ctype(me.datagrid.items(ItIndex ).cells(intddColumn1).findcontrol("dd2"),dropdownlist).datasource = YourDataSource ctype(me.datagrid.items(ItIndex ).cells(intddColumn2).findcontrol("dd2"),dropdownlist).databind You welcome! emorales mcdba, mcad, mcsd

          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