.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

dynamic dropdownlist problem !

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :ASP.Net

hi ,

I have dynamic dropdownlist .. and I need to get values when submit !

so what i can write ?

I tryed : foreach(DropDownList ddl in Page.Form.Controls) .. didnt work !!

I work with C#

View Complete Post

More Related Resource Links

Problem with Dynamic Button


Hi friends,

I am trying to make a page inspired from http://login.qlikview.com/help.aspx

here I have made a dropdownlist and on clicking I am able to dynamically add the textboxes and radio buttons using placeholders. My problem is I am not able to use a dynamic number of submit buttons. In the page (link above) I need to make the submit button available for two choices and invisible for one.  But the option dynamicbutton is not available alike dynamicTextboxes etc. What could I do? Is there any other way I could figure out to implement this.

Thanking you in advance,


styling dropdownlist problem


Dear All,

im facing a problem while styling my ddl, what i did is:

<div><asp ropDownList ID="DropDownList1" runat="server" style="background-color:Transparent;" Width="100%">
    </asp: dropDownList></div>

<div class="stlGradient">
<asp ropDownList ID="DropDownList1" runat="server" style="background-color:Transparent;border:none;" Width="100%"></asp: dropDownList>

the DIV style is having a bg image repeated X.

now this worked on Firefox
on google Chrome: the border gone but the background still white
on IE 7: nothing happend

thanks for helping.

Problem with Dynamic Controls



I have a custom user control that contains within it a repeater control. Inside this repeater I programmatically add another custom user control, which contains a text box and a custom validator. This final custom user control can be added any number of times depending on the application's logic. All of this is part of a wizard step.

When the user completes the step, if any of the data added to the text boxes is incorrect the validator gets fired on post back. However, because I can have any number of these controls added to the repeater, the user has to scroll down to see any of the incorrectly completed boxes.

Due to the controls being added dynamically it is not possible to use a validation summary control - I have tried!!! Therefore, is there away I can use JavaScript to position a cursor or to jump to each incorrectly completed textbox without the user needing to scroll down the page? For example, if there are 10 textboxes, and textboxes 8 and 9 have numbers inside them inside strings, then the JavaScript should jump textbox 9.

Weird problem in Detailsview - Dropdownlist in



I'm new in this forum and I really hope you'll be able to help me.

I converted a field in the detailsview into a template field and put a dropdownlist in the <InsertItemTemplate> and it worked great. This is the code I put:

<InsertItemTemplate><asp:DropDownList runat="server" DataSourceID="sdsGenresPossible" DataTextField="Genre"  DataValueField="Index" SelectedValue='<%# Bind("Genre") %>' ></asp:DropDownList></InsertItemTemplate>

Now, I tried to do the same thing for the <EditItemTemplate> . This is the code I put there:

<EditItemTemplate><asp:DropDownList runat="server" DataSourceID="sdsGenresPossible" DataTextField="Genre" DataValueField="Index" SelectedValue='<%# Bind("Genre") %>' ></asp:DropDownList></EditItemTemplate>  

When I change the DV properties I do see that a dropdownlist was  added but when I run the program and click on "Edit" in the DV nothing happens (however when I click on "Insert" it works fine).

This is the Select command for the data source I used:

<asp:SqlDataSource runat="server"

ListItem Dynamic DropDownList based on custom list entries.

I utilized the following solution to get the drop down list on the page and populate it dynamically, but it doesn't save the selected value back to the SPListItem object. Does anyone have a better solution possibly for this? http://geekswithblogs.net/SoYouKnow/archive/2010/01/21/sharepoint-populating-drop-down-list-field-with-data-from-different.aspx

ASP.Net MVC Dropdownlist and selected value problem

I was able to create a dropdownlist for my MVC project, but the value is not selected as  selected value on the dropdownlist. It just shows whole county list from the first.The value is from database. I tried find it from previous post, but it was quite confusing. Please, suggest me for any idea. Controller Code public ActionResult Edit(int i) {      var items = new SelectList(db.MST_COUNTRies.ToList(), "COUNTRY_ID", "COUNTRY_NM");      ViewData["MST_COUNTRies"] = items; } View Code <p>     <%= Html.DropDownList("COUNTRY_ID", (SelectList)ViewData["MST_COUNTRies"])%> </P>I was able to create a dropdownlist for my MVC project, but the value is not selected as  selected value on the dropdownlist. It just shows whole county list from the first.The value is from database. I tried find it from previous post, but it was quite confusing. Please, suggest me for any idea.Controller Codepublic ActionResult Edit(int i){     var items = new SelectList(db.MST_COUNTRies.ToList(), "COUNTRY_ID", "COUNTRY_NM");     ViewData["MST_COUNTRies"] = items;}View Code<p>    <%= Html.DropDownList("COUNTRY_ID", (SelectList)ViewData["MST_COUNTRies"])%></P>

Problem with Dynamic Controls inside an UpdatePanel

Hello Everybody ,I have this problem,if anyone could help me i'll be so gratefull. I had been created some dynamic radio buttons in a loop inside a dinamy table which is inside an UpdatePanel , but i can not handle the events my code is below:public void MetodoCreacion(){RadioButton RBtn = null;Table table = new Table();TableRow row = null;TableCell cell = null;for (int i = 0; i < 5; i++){row = new TableRow();cell = new TableCell();RBtn = new RadioButton();RBtn.ID = "RBGN_" + i.ToString();RBtn.GroupName = "RBGN1";RBtn.Text = "Opcion " + i.ToString();RBtn.CheckedChanged += new EventHandler(RBtn_CheckedChanged);RBtn.AutoPostBack = true;cell.Controls.Add(RBtn);row.Controls.Add(cell);table.Controls.Add(row);}UpdatePanel1_UpdatePanelAnimationExtender.Controls .Add(table);}public void RBtn_CheckedChanged (object sender, EventArgs e){Label1.Text = ((RadioButton)sender).ID;}and the controls doesent call the event ...thanks a lot

Problem Binding DropdownList in a gridView to a datasource

I have a Dropdownlist in an itemTemplate in a gridview. My gridView binds to dataTable1 (from which the selected value for dropdown comes from) and dropDown binds to dataTable2 (i need to get DataValueField and DataTextField from here).<asp:TemplateField HeaderText="Category"> <ItemTemplate> <asp:DropDownList ID="Cat" runat="server" SelectedValue='<%#Bind("CATEGORY") %>' > </asp:DropDownList> </ItemTemplate> <FooterStyle BorderStyle="None" /> <HeaderStyle BorderStyle="None" /> <ItemStyle BorderStyle="None" /> </asp:TemplateField>How do I do that? thanks in advance!

ASP.Net Dynamic Data - DropDownList Field Template with AJAX Cascading DropDown Extension

Hi all,   Have spent hours trying to create a Dynamic Data Field Template holding a DropDownList which is extended by the AJAX Cascading DropDown extension. Final form holds multiple cascading dropdown boxes. User selects Country (Land) then Postcodes, Counties (Provincie) are populated. Once postcode is selected then towns (Plaats) are populated.  The problem I am now facing is that the viewstate for the dropdown lists is not being saved/restored after an insert action or custom validation error. So basically the dropdown lists are being reset to their default values. Some code (if missing parts, just ask and I will post them) - Don't mind the code structures etc... needs some refactoring :) Attribute I created:using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Data { [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] sealed public class CascadingDropDownParametersAttribute : Attribute { //public string TargetControlID; // The ID of the DropDownList to populate. public string Category; // The name of the category this DropDownList represents. public string PromptText; // Optional text to display before the user has selected a value from the DropDownList. public string

JQuery with dynamic ASP.NET controls (DropDownList)

I am mixing JQuery with ASP.NET webforms.  Adding dynamic controls and accessing the selected values with JQuery works differently under different circumstances and I am trying to establish the difference. Why does Senario 1 work in debug mode but not without breakpoints?  What does databinding to a GridView do that adding DropDownList controls to a asp:panel does not? Is there some sort of DOM registration going on in DataBind? All senarios use the same JQuery: var ddlCollection = $("select[name$='ddlDynamicDropDown']") Senario 1: Breakpoints on each line (Success) Add DropDownList controls to a asp:panel dynamically in the PageLoad method (Does the page lifecycle matter? OnLoad method instead?). Run the code Select values and click on a button firing a JavaScript function (Break in Debug) Break in JavaScript file Access the dropdowns and their selected values successfully Senario 2:  Run the Senario 1 code without breakpoints (Fails to locate the ddlCollection) Senario 3: Use a GridView (Success) Add values to populate the DropDownList controls to a Generic List. Bind the values to a GridView control containing the DropDownList controls Run the code Select values and click on a button firing a JavaScript function Use JQuery to Access the dropdowns and their selected values successfully.  

Problem binding data to DropDownList in DetailsView

Hi guys. I have a slight issue I awas trying to fix for 2-3 days, but nothing I try works. The scenario: DetailsView control in edit mode, I pass parameters to the SqlDataSourceProducts (edit.aspx?id=2) and the data source selects the appropriate data and fills in the DetailsView form. Except two drop down lists. These two DDLs (DDL2 and DDL3) are dependent on the previous DDL (DDL1) in the DetailsView. Thanks to PeteNet, when the selected value of the DDL1 changes, DDL2 and 3 change their lists and get bound to the database. The problem is: when I edit something from the database, DDL2 and 3 appear empty and when I update any other field and leave these, they get blanked in the database.  My goal is to set the selected value of DDL2 and 3 to the values in the database WHERE ID = QueryStringField="id". I can go for not binding the data unless the field is changed, but does not sound professional and user friendly. code: The SqlDataSource used to select the parameters from the table and populate the DetailsView <asp:SqlDataSource ID="SqlDataSourceProduct" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT ID, wm_number, upc, check_digit, unit, price_unit, brand, category, shelves, type, cooking, storage, packaging, origin, nutriti

Dynamic DropDownList ListItemCollection - Event Handler

Hi and thanks in advance. Description: I am building drop downs dynamically then adding them to a panel, when postback occurs it does not hit my event handler. However I CAN get the event handler to be hit if I remove(comment out) the properties DataTextField and DataValueField while I am rebuilding the dropdownlist within OnInit on eachpostback. However when the dropdownlist is in this condition the sender to the eventhandler does not have it's properties like SelectedValue[Index] set. Step 1: Build and load a drop down. The following is the event handler for selectedindexchanged on the lists.  The drop down list is bound to a ListItemCollection that represent a few fields from a datatable. This dropdown is loaded into a panel and the panel in turn is loaded into a div. All of this functions as intended.protected void AnswerDDL_SelectedIndexChanged(object sender,EventArgs e) { int _nextQuestionID; DropDownList _ddlSender = new DropDownList(); _ddlSender = (DropDownList)sender; _nextQuestionID = Convert.ToInt32(_ddlSender.SelectedValue); DropDownList _newAnswerDDL = new DropDownList(); _newAnswerDDL = GetAnswerDropDown(_nextQuestionID); this.m_panel.Controls.Add(_ne

dropdownlist selected value problem

i have dropdownlist<%= Html.DropDownListFor(model => model.SchoolDistrict,Model.sSchoolDistrict) %>To Poulate this value i have below code in controllerslist = new SelectList(list, "ID", "Name", selected);but what ever selected value i pass didnot shown in ddl

Dynamic Text Boxes Creation Problem

Hi all, I am creating 5 textboxes in a row. A new creates when user press enter in the last textbox. I have taken a hidden text field and in OnKeyDown of last textbox I am assigning the combination of last textbox Id with the table count  to the hidden field and in VB Code I am checking whether the tableCount + Last textbox Id is equal to the hidden field or not then only I am generating the new row. here is the code In JavaScript On KeyDown of remarks textfield. function funcNewRow(id,count,e) {    var e = event || evt;    var charCode = e.which || e.keyCode;    if(charCode == 13){      e = cancelKey(e);      htxtBox.value = id + count;    } }   In VB Page_load method calling getTableRow() method   if htxtBox.value = "remarks" & (Tbl.Rows.Count + ViewState("TotalClearedItems")) Then  Tbl.Rows.Add(GetTableRow(Tbl.Rows.Count + 1 + ViewState(Panel1.Controls.Add(Tbl))  Panel1.Controls.add(Tbl) htxtBox.Value = "" end if   Here I have to implement a clear functionality such as each row at last contains a check box when user click the check box and press clear button the checked rows have to deleted .   The clear button code as follows : cnt = CInt(Tbl.Rows.Count)  For i = cnt To 1 Step -1 c = Pag

dropdownlist - css - problem chrome


          <asp:Label ID="Label18" runat="server" Text="Vrsta kreditne kartice"></asp:Label></span><span
class="formw"><asp:DropDownList ID="DropDownList2" Selected="True" width="200px" runat="server">
              <asp:ListItem>Diners Club Card</asp:ListItem>

div.row {
  clear: both;
  padding-top: 5px;

div.row span.label {
  float: left;
  width: 175px;
  text-align: left;

div.row span.formw {
  float: left;
  width: 500px;
  text-align: left;
/*  margin:0 0 0 10px;*/


I have a

Problem with displaying and processing dynamic data


I need to dynamically generate a list of images in table format.  The images can be found in either art or picts, in temp, or in temp and in one of the other two (duplicate image). 

The idea is to display any duplicates prior to copying anything over from temp to either art or picts, so I'm thinking of adding radio buttons if the same image is found in two folders.  I also want to add a submit button.  The user selects the image they want and clicks the button.  If they want the new file it's copied over then deleted.  If they want to keep the existing file the new one is just deleted.  If they select nothing, both versions of the file are deleted.  So the table will look something like this:

temp         art            picts         process
z-123                                           delete button
() z-234                       () z-234  

Postback Problem using Lightbox with DropDownList


Hi all,

I have two sites: "Default.aspx" and "mySubsite.aspx". In "Default.aspx" I have a hyperlink to open a lightbox window, which works perfectly.

Here is the code for it:

<asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
<a href="mySubsite.aspx" class="lbOn">Open Lightbox Window</a>

When the lightbox window opens("mySubsite.aspx.cs") I placed two drop down lists ( parent child use) . First DDL contains all the parent names and the second DDL returns the subname to the corresponding parent name. So basically I select a parent item and get the right subname for it.

Code for it looks this way.

protected void Page_Load(object sender, EventArgs e)

if (!IsPostBack)
DDLParent.DataSource = data_string;


protected void DDLParent_SelectedIndexChanged(object sender, EventArgs e)

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend