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. how to bind the data from dropdownlist when dropdown is in datagrid or gridview

how to bind the data from dropdownlist when dropdown is in datagrid or gridview

Scheduled Pinned Locked Moved ASP.NET
csstutorial
3 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.
  • P Offline
    P Offline
    praveenanand
    wrote on last edited by
    #1

    hi all i have a dropdownlist in datagrid and have to populate it data in pageload along with grid.later i have to fire the ddlselectedindex when it is in grid

    X 1 Reply Last reply
    0
    • P praveenanand

      hi all i have a dropdownlist in datagrid and have to populate it data in pageload along with grid.later i have to fire the ddlselectedindex when it is in grid

      X Offline
      X Offline
      xibeifeijian
      wrote on last edited by
      #2

      Use the gridview's RowCreated Event.I just write a example and tested it: protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { GridView g = (GridView)sender; if (g.Rows.Count == 0) { return; } DropDownList ddl = (DropDownList)g.Rows[g.Rows.Count-1].FindControl("ddl"); if (ddl != null) { object[] array = new object[] { DateTime.Now.ToString() }; ddl.DataSource = array; ddl.DataBind(); } } When you get ddl you can do it yourself.:)

      :^):^):^):^):^):^):^):^):^):^):^):^) :^):rose::rose::rose::rose::rose:▒▒〓▒〓▒▒ :^):rose::^):^):^):^)▒〓〓〓〓〓▒ :^):rose::^):^):^):^)▒▒〓▒〓▒▒ :^):rose::^):^):^):^)▒〓〓〓〓〓▒ :^):rose::rose::rose::rose::rose:▒▒〓▒〓▒▒ :^):^):^):^):^):^):^):^):^):^):^):^)

      X 1 Reply Last reply
      0
      • X xibeifeijian

        Use the gridview's RowCreated Event.I just write a example and tested it: protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { GridView g = (GridView)sender; if (g.Rows.Count == 0) { return; } DropDownList ddl = (DropDownList)g.Rows[g.Rows.Count-1].FindControl("ddl"); if (ddl != null) { object[] array = new object[] { DateTime.Now.ToString() }; ddl.DataSource = array; ddl.DataBind(); } } When you get ddl you can do it yourself.:)

        :^):^):^):^):^):^):^):^):^):^):^):^) :^):rose::rose::rose::rose::rose:▒▒〓▒〓▒▒ :^):rose::^):^):^):^)▒〓〓〓〓〓▒ :^):rose::^):^):^):^)▒▒〓▒〓▒▒ :^):rose::^):^):^):^)▒〓〓〓〓〓▒ :^):rose::rose::rose::rose::rose:▒▒〓▒〓▒▒ :^):^):^):^):^):^):^):^):^):^):^):^)

        X Offline
        X Offline
        xibeifeijian
        wrote on last edited by
        #3

        I've forgotten to remind you that ddl is the DropDownList's id in the GridView.:-O

        :^):^):^):^):^):^):^):^):^):^):^):^) :^):rose::rose::rose::rose::rose:▒▒〓▒〓▒▒ :^):rose::^):^):^):^)▒〓〓〓〓〓▒ :^):rose::^):^):^):^)▒▒〓▒〓▒▒ :^):rose::^):^):^):^)▒〓〓〓〓〓▒ :^):rose::rose::rose::rose::rose:▒▒〓▒〓▒▒ :^):^):^):^):^):^):^):^):^):^):^):^)

        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