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 populate dropdownlist within the grid?

How to populate dropdownlist within the grid?

Scheduled Pinned Locked Moved ASP.NET
helpcsssysadmintutorialquestion
3 Posts 3 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
    moomoooomoo
    wrote on last edited by
    #1

    hello everyone, I need your help once again. Had a problem in populating dropdownlist within the grid. Anyone pls help.. <EditItemTemplate> <asp:DropDownList CssClass="CellValue" ID="ddlCategories" Runat="server" Width="100%"></asp:DropDownList> </EditItemTemplate> code behind:: private void gvDisclosures_ItemDataBound(object sender, EventArgs e) { DropDownList list = (DropDownList) e.Item.FindControl("ddlCategories"); // Set the text and value properties // for the dropdown list to appropriate columns in the // data source list.DataTextField = "fcCatCode"; list.DataValueField = "fcCatCode"; list.DataSource = m_uf.loadCategory(); list.DataBind(); } when i click the edit button.... i always encounter an error on the behind code: can someone help me on this one.. your help is highly appreciated tnx. :laugh: start a new beginning in every ending; thats what life for......

    P C 2 Replies Last reply
    0
    • M moomoooomoo

      hello everyone, I need your help once again. Had a problem in populating dropdownlist within the grid. Anyone pls help.. <EditItemTemplate> <asp:DropDownList CssClass="CellValue" ID="ddlCategories" Runat="server" Width="100%"></asp:DropDownList> </EditItemTemplate> code behind:: private void gvDisclosures_ItemDataBound(object sender, EventArgs e) { DropDownList list = (DropDownList) e.Item.FindControl("ddlCategories"); // Set the text and value properties // for the dropdown list to appropriate columns in the // data source list.DataTextField = "fcCatCode"; list.DataValueField = "fcCatCode"; list.DataSource = m_uf.loadCategory(); list.DataBind(); } when i click the edit button.... i always encounter an error on the behind code: can someone help me on this one.. your help is highly appreciated tnx. :laugh: start a new beginning in every ending; thats what life for......

      P Offline
      P Offline
      Parwej Ahamad
      wrote on last edited by
      #2

      Can you post here error and on which line ?

      Parwej Ahamad R & D: REST services with WCF

      1 Reply Last reply
      0
      • M moomoooomoo

        hello everyone, I need your help once again. Had a problem in populating dropdownlist within the grid. Anyone pls help.. <EditItemTemplate> <asp:DropDownList CssClass="CellValue" ID="ddlCategories" Runat="server" Width="100%"></asp:DropDownList> </EditItemTemplate> code behind:: private void gvDisclosures_ItemDataBound(object sender, EventArgs e) { DropDownList list = (DropDownList) e.Item.FindControl("ddlCategories"); // Set the text and value properties // for the dropdown list to appropriate columns in the // data source list.DataTextField = "fcCatCode"; list.DataValueField = "fcCatCode"; list.DataSource = m_uf.loadCategory(); list.DataBind(); } when i click the edit button.... i always encounter an error on the behind code: can someone help me on this one.. your help is highly appreciated tnx. :laugh: start a new beginning in every ending; thats what life for......

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        moomoooomoo wrote:

        DropDownList list = (DropDownList) e.Item.FindControl("ddlCategories");

        Whatever the error is, you should never call find control, do the cast instead of using 'as' and then just use it right away. Write defensive code, that will not blow up if the FindControl call fails. Try to write a site that won't ever blow up, even if it doesn't work as you hope for some reason. I am suspecting that is what's happening, b/c that's all I can see that could go wrong.

        Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        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