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. TemplateColumn:DropDownList Edit Selected Item

TemplateColumn:DropDownList Edit Selected Item

Scheduled Pinned Locked Moved Web Development
questioncsscomsysadmindocker
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.
  • M Offline
    M Offline
    MStanbrook
    wrote on last edited by
    #1

    I've hit a wall. I'm working with a web-based DataGrid, using Template Columns bound to a dataset. Once column contains a text box for the Item template and DropDownList for the Edit Template. The Dropdowns are populated from a DataTable within the DataSet being used. Everything displays properly (i.e. the DDL contains all of the expected values), but upon entering the "edit mode" for a row, the DropDownList is always set to the FIRST entry! How can I get the DDL to select the correct value? Not sure if this will make it more or less clear...:wtf: <asp:TemplateColumn HeaderText='Company Name'> <ItemTemplate>    <asp:Label id=Label3 runat='server' Text='<%# DataBinder.Eval(Container,'DataItem.CompanyName') %>'>    </asp:Label> </ItemTemplate> <FooterTemplate>    <asp:dropdownlist DataSource='<%# GetCompanies() %>' DataTextField='Name' DataValueField='CompanyID' runat='server' ID='cmbFooterCompanyID'>    </asp:dropdownlist> </FooterTemplate> <EditItemTemplate> <asp:dropdownlist DataSource='<%# GetCompanies() %>' DataTextField='Name' DataValueField='CompanyID' runat='server' ID='cmbEditCompanyID'> </asp:dropdownlist> </EditItemTemplate> </asp:TemplateColumn> Thanks. Mike Stanbrook mstanbrook@yahoo.com

    T 1 Reply Last reply
    0
    • M MStanbrook

      I've hit a wall. I'm working with a web-based DataGrid, using Template Columns bound to a dataset. Once column contains a text box for the Item template and DropDownList for the Edit Template. The Dropdowns are populated from a DataTable within the DataSet being used. Everything displays properly (i.e. the DDL contains all of the expected values), but upon entering the "edit mode" for a row, the DropDownList is always set to the FIRST entry! How can I get the DDL to select the correct value? Not sure if this will make it more or less clear...:wtf: <asp:TemplateColumn HeaderText='Company Name'> <ItemTemplate>    <asp:Label id=Label3 runat='server' Text='<%# DataBinder.Eval(Container,'DataItem.CompanyName') %>'>    </asp:Label> </ItemTemplate> <FooterTemplate>    <asp:dropdownlist DataSource='<%# GetCompanies() %>' DataTextField='Name' DataValueField='CompanyID' runat='server' ID='cmbFooterCompanyID'>    </asp:dropdownlist> </FooterTemplate> <EditItemTemplate> <asp:dropdownlist DataSource='<%# GetCompanies() %>' DataTextField='Name' DataValueField='CompanyID' runat='server' ID='cmbEditCompanyID'> </asp:dropdownlist> </EditItemTemplate> </asp:TemplateColumn> Thanks. Mike Stanbrook mstanbrook@yahoo.com

      T Offline
      T Offline
      Todd Smith
      wrote on last edited by
      #2

      You need to set the selectedindex property of the dropdownlist. Todd Smith

      M 1 Reply Last reply
      0
      • T Todd Smith

        You need to set the selectedindex property of the dropdownlist. Todd Smith

        M Offline
        M Offline
        MStanbrook
        wrote on last edited by
        #3

        Todd Smith wrote: You need to set the selectedindex property of the dropdownlist. I've tried, but I'm not sure WHERE or WHEN (in the page lifecycle) that should be set. Also, I am not clean on how to get the index from the Dataset/DataTable where the values are stored. Mike Stanbrook mstanbrook@yahoo.com

        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