Dynamically loaded drop down list from server side are not available to access on submit from server side

my requirement is store the drop down list items filled dynamically(from server side) in a user control on submit button. problem # On submit button i am unable to get the drop down list items on server side they are null. Can you guys please suggest me what is the best way to acesss the drop down list items

on page load

ddlCCFirstBTFXMethod.DataSource = tdatasource; ddlCCFirstBTFXMethod.DataTextField = "Key"; ddlCCFirstBTFXMethod.DataValueField = "Value"; ddlCCFirstBTFXMethod.DataBind();

on submit

var a = ddlCCFirstBTFXMethod.Items.Cast<ListItem>().ToDictionary( i => i.Text,i => i.Value);

-------------Problems Reply------------

You should have a If(!IsPostBack()) so you code will look something like this.

if (!IsPostBack())
{
ddl.DataSource = source;
ddl.DataTextField = "Key";
ddl.DataValueField = "Value";
ddl.DataBind();
}

On Submit

foreach(var item in ddl.Items)
{
Response.Write(String.Format("Text : {0}, Value: {1}",item.Text, item.Value);
}

Category:c# Views:0 Time:2011-07-05
Tags: .net asp.net

Related post

  • Dynamically loading form with jQuery 2011-12-18

    I'm learning web design and have run into a difficulty that I can't figure out by myself. I want to dynamically load a form into a using jQuery. My code looks like this: From within the main file: $('#left_colum').click(function(e) { e.preventDefault

  • Jquery .on event with selector for dynamically loaded elements with selectors 2012-03-20

    I am modifying the jquery.unobtrusive-ajax.js that is packaged with asp.net mvc 3 to allow dynamically loaded forms to work. Old: $("form[data-ajax=true]").live("submit", function (evt) { /*code here */ }); My code: $("body").on("submit","form[data-a

  • How do I import MS Access data into SQL Server using SSIS package? 2011-07-15

    I've spend the better part of a day looking around for anything to help me, but SSIS is such a huge tool that nothing is of any use so far, or maybe I just don't understand it. I need to take an old Access db that has some problems and move it into s

  • How we can resolve the datetime problem shifting the Access DB from production server to live 2009-04-03

    Can you advice best way to rectify timezone issues in .Net. Recently I developed a simlple website by using asp.net C# as codebehind adn MS Access as backend. My production server and live servers are in different date time setting. My producttion se

  • How can I dynamically load and execute Javascript from the server without using eval()? 2010-12-22

    I'm writing a PHP framework which allows PHP developers to create ExtJS interfaces with forms, grids, tabpanels and menus using PHP classes only. In order to create a TabPanel, for example, a PHP class is instantiated with an array of URLs which get

  • Dynamically add drop down lists and remember them through postbacks 2009-08-10

    I'm trying to figure out the best way to achieve this: I need to show a drop down list when the page loads, the default selected value is nothing, or an empty element (such as "-"). When the user selects one value from the list, another drop down lis

  • How can I dynamically load and execute all of the Javascript files in a directory? 2010-04-05

    I'm making a very simple content-management system in Javascript. It uses plugins which are individual .js files which live in a "modules" folder. Currently I'm loading them with JQuery's getScript() function, but I have to manually define the list o

  • How do I maintain drop down selections on a page with many dynamically named drop down lists in asp.net mvc 2? 2011-04-05

    I've read the links listed when I was creating this question. I think what I'm trying to do differs slightly. I am using ASP.NET MVC 2. Apologies for the incoming wall of text. The most brief way I can think to ask this question is immediately below.

  • Problem while trying to dynamically populate drop down menu in jsp (am using struts 2 framework) 2011-08-03

    (Sorry for the length of the post!!) edit: By dynamically I mean--> when the selection of a drop down changes I want the contents of other drop downs to change as well. Thanks!! I am trying to dynamically populate dropdown menu in jsp (I guess thi

  • Dynamically loading content in div using select list 2015-01-19

    I am trying to load contents in div section using the drop down select menu. When user selects any category, contents of that category should be displayed. (I don't want to make different page for every category,just update the contents based on sele

  • Dynamically load a JavaScript file 2008-08-21

    How can you reliably and dynamically load a JavaScript file? This will can be used to implement a module or component that when 'initialized' the component will dynamically load all needed JavaScript library scripts on demand. The client that uses th

  • How to make Jetty dynamically load "static" pages 2008-10-08

    I am building Java web applications, and I hate the traditional "code-compile-deploy-test" cycle. I want to type in one tiny change, then see the result INSTANTLY, without having to compile and deploy. Fortunately, Jetty is great for this. It is a pu

  • Failed to load viewstate when dynamically loading different controls 2008-12-05

    I have an aspx page which is loading some controls dynamically on postback (ie when a click event happens) and adding them to a placeholder. Depending on what is clicked a different set of controls needs to be loaded. This works perfectly the first t

  • Dynamic loading of modules in Java 2009-01-06

    In Java, I can dynamically add stuff to classpath and load classes ("dynamically" meaning without restarting my application). Is there a known framework/library which deals with dynamic loading/unloading of modules without restart? The usual setup, e

  • Dynamically Load HTTP Modules, Possibly with Unity? 2009-01-15

    Has anyone seen any how-to, documentation, or otherwise about how to load HTTP Modules dynamically for IIS? Basically what I am trying to do is to load HTTP Modules, which I'll call HTTPModuleA, HTTPModuleB, and HTTPModuleC. The modules however could

  • GWT Dynamic loading using GWT.create() with String literals instead of Class literals 2009-01-16

    GWT.create() is the reflection equivalent in GWT, But it take only class literals, not fully qualified String for the Class name. How do i dynamically create classes with Strings using GWT.create()? Its not possible according to many GWT forum posts

  • Dynamically loaded User control ID and javascript 2009-02-14

    I have a host page that dynamically loads multiple instances of the same user control by assigning different IDs. After the UC loads, I will need to use JS to get a reference to a textbox. For this, I need the User control Client ID. I do have access

  • Dynamically load additional jar files using Web Start / JNLP 2009-03-18

    The Web Start Developers Guide states All application resources must be retrieved from the JAR files specified in the resources section of the JNLP file, or retrieved explicitly using an HTTP request to the Web server. Storing resources in JAR files

  • Dynamically load CSS in Actionscript/Flex 2009-04-14

    Problem Definition: To be able to dynamically load a CSS at runtime to skin a Flex Application. More Information: I've found that loading and applying a CSS is as simple as using "mx:style source="../assets/default.css"". But what I would like to do

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.127 (s). 11 q(s)