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. Selectedindex in datadropList in datagrid

Selectedindex in datadropList in datagrid

Scheduled Pinned Locked Moved ASP.NET
databasecomsysadminquestionlearning
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.
  • H Offline
    H Offline
    hasanali00
    wrote on last edited by
    #1

    I want to set the selectedindex of a datadroplist in a datagrid. I have following method to get which index to display: public int SetNewCompanyIndex(object cname) { int com = int.Parse(cname.ToString()); int companyID = com - 1; return companyID; } Next, I have: " runat="server" > But this does not display the DDl. If I remove SelectedIndex from the above code, I can display the DDL, but of course, it does not set the proper selected index. So how can I make DDL to display the chosen Selected index thanks

    U 1 Reply Last reply
    0
    • H hasanali00

      I want to set the selectedindex of a datadroplist in a datagrid. I have following method to get which index to display: public int SetNewCompanyIndex(object cname) { int com = int.Parse(cname.ToString()); int companyID = com - 1; return companyID; } Next, I have: " runat="server" > But this does not display the DDl. If I remove SelectedIndex from the above code, I can display the DDL, but of course, it does not set the proper selected index. So how can I make DDL to display the chosen Selected index thanks

      U Offline
      U Offline
      utsav_verma
      wrote on last edited by
      #2

      Hi hasan well, shld b an easy task, try d following - private void dg_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { DropDownList lst=(DropDownList)e.Item.FindControl("ddl"); if(lst!=null) lst.SelectedIndex=SetNewCompanyIndex(e.Item.ItemIndex+1); } here dg is datagrid n ddl is the dropdownlist UTSAV

      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