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

Top 5 Contributors of the Month
Post New Web Links

DropDownList data from XML

Posted By:      Posted Date: September 14, 2010    Points: 0   Category :ASP.Net
 Hi All- I am using XMLDataSource to populate DropDownList.  It works fine but I have issue at displaying subset of the xml data.  My sample xml data is as below-  <?xml version="1.0" encoding="utf-8" ?> <templates> <cat1> <design id="A1" title="A1" visibility="true"/> <design id="A2" title="A2" visibility="true"/> <design id="A3" title="A3" visibility="false"/> <design id="A4" title="A4" visibility="false"/> </cat1> <cat2> .... .... </templates> I was playing with xpath expressions like XPath="templates/cat1/design[visibility='true']" to display all cat1 designs where visibility is true.  So it should return 3 records but it wouldnt show anything.. Can someone please help/guide me?  I am using visibility flag to display/ignore that item in dropdown.. Thanks in advance ...  

View Complete Post

More Related Resource Links

Data Binding to Dropdownlist


   private void AddDBDataToControl(DataSet app_Support,int count)
        int i = 0;
        while (count != 0)

            DateTime dt = Convert.ToDateTime(app_Support.Tables[0].Rows[i]["FromDate"].ToString());

//dt=23/08/2010 10:04:00 AM

            DropDownList h1 = (DropDownList)GVDate.Rows[i].Cells[1].FindControl("txthour");
            h1.SelectedValue = dt.Hour.ToString();
            DropDownList m1 = (DropDownList)GVDate.Rows[i].Cells[2].FindControl("txtmin");
            m1.SelectedValue = dt.Minute.ToString();

            DropDownList h2 = (DropDownList)GVDate.Rows[i].Cells[5].FindControl("txthourto");
            DateTime dt2 = Convert.ToDateTime(app_Support.Tables[0].Rows[i]["To

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

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

dropdownlist programmically fills data in webform?



I am trying to get a dropdownlist to fill a webform. 

My approach is to have the dropdownlist to be bound with data from the database.  OnSelectedIndexChange for the dropdownlist, I would like to query the database to get the form data.  Once the form is filled, changes can be made, then saved again...writing changes back to the database.

These seems very simple, but I am stuck.  My dropdownlist posts to the server to get the data, but I think this is submitting my form...which cannot have some empty form fields.

What I am looking for is a new way to approach this task ( I have gotten tunnel vision ).


LINQ how to get data from dropdownlist in label1


            var dnevnice = from p in db.tbl_dnevnices
                         select p.Drzava;

            ddlDnevnice.DataSource = dnevnice;

I have label1.text.

Example: ID

How to display data according to the selected data in DropDownList?

manage a dropdownlist though data source



all of you, actuly i am a new user of asp.net and i am a learner so i just want to connect two dropdownlist to data souce  and i want that the list item of second dropdown is changed according to change of selected item of first dropdown.

i have connect it to data source successfully it getting chaged items but it happance only when its load then if i select the next item of first one it would not work properly,

so please solve my problem i think you definatly give the answer.

thank you !

Help: populate Html.DropDownList from table data? [Linq to SQL model]


I have two tables, Users and Roles.  The roles table is a reference table for the different roles of my site (RoleId and RoleName columns). The Users table contains profile data for each user, including a RoleId column that is FK'd back to the Roles table [RoleId].

Both tables are in a Linq to SQL model.

I have an edit page created which lists all the profile values of a user.  The edit page inherits the User model.  One of the editable values is the RoleId field.  I want to set this up to be a drop-down list that contains items labeled using the RoleName column of the Roles table, and matched with values of RoleId.

How can I achieve this?

dropdownlist in gridview not keeping data value?


I've got a gridview which contains a dropdownlist.  I've got it binding to display the correct name, but when I go to update it (and it could be the dropdownlist field or any other the other fields), I get an error stating it can't update the row because addr_cnt doesn't allow null fields.  I've tried just about everything I can find to get it to keep the addr_cnt value, but nothing seems to be working.  My code is below:

<asp:GridView id="gvLeader" runat="server" AutoGenerateColumns="False" datakeynames="ldr_id" DataSourceID="dsLeaders" GridLines="Vertical">
   <asp:BoundField DataField="ldr_id" HeaderText="id" visible="false">
   <asp:TemplateField HeaderText="Leader Name">
     <asp:DropDownList id="ddlLeadID" runat="server" AutoPostBack="True" DataSourceID="dsAddr1" DataTextField="lead_name" Width="175px" DataValueField="addr_cnt" SelectedValue='<%# Bind("laddr_cnt") %>' >

How to get two data in dropdownlist with Linq


var customers = from c in db.tbl_relacije_sifrants
                        select new

        ddlRelacijeSifrant.DataSource = customers;
        ddlRelacijeSifrant.DataTextField = "Relacija";
        ddlRelacijeSifrant.DataValueField = "ID";

I need Two Pieces of data and the DropDownList.

Relationship + SifraId = DropDownList

What do I do?


Why can not I choose the first data - DropDownList



protected void ddRelacijeSifrant_SelectedIndexChanged(object sender, EventArgs e)

        var getID = (from p in db.tbl_relacije_sifrants
                     where p.ID == Convert.ToInt32(ddlRelacijeSifrant.SelectedValue)
                     select p).SingleOrDefault();

        txtRelacija.Text = getID.Relacija;
        txtKm.Text = Convert.ToString(getID.Kilometrov);


        ID="ddlRelacijeSifrant" AutoPostBack="True" DataTextField="" 
                DataValueField="" runat="server" 
        onselectedindexchanged="ddRelacijeSifrant_SelectedIndexChanged" Visible="False" 

If I have only one data you can not choose.

The table "table1", I have data "test1"

This data can not select and display data in txtrelacija and txtkm

If I have a table "table1", I data
I have to select the first test2, test before you can see test1

What's wrong?

Connecting dropdownlist to a data source



I have a external list. I changed the textbox available for Student Id column and made it as a dropdownlist. Now I want to connect the datasource to the dropdownlist. I clicked on Data fields.  In the change data bindings,  in the select datasource, i selected the datasource, data field for display text, i selected Student id, in the data field for value, i selected the student Id. Clicked on ok. In the Preview browser, when i try to view the page, i am getting error as Object reference not set error"

How to connect a dropdownlist to a datasource?

Thank you

Binding WPF Controls to an Entity Data Model

In this interview, programming writer, McLean Schofield, demonstrates how to bind WPF controls to an entity data model, using Visual Studio 2010 Beta 1. You can also learn more in the topic: Walkthrough: Binding WPF Controls to an Entity Data Model.

Surrogate vs Natural Primary Keys - Data Modeling Mistake 2 of 10

In case you're new to the series I've compiled a list of ten data modeling mistakes that I see over and over that I'm tackling one by one. I'll be speaking about these topics at the upcoming IASA conference in October, so I'm hoping to generate some discussion to at least confirm I have well founded arguments.

The last post in this series Referential Integrity was probably less controversial than this one. After all, who can argue against enforcing referential integrity? But as obvious as surrogate keys may be to some, there is a good deal of diversity of opinion as evidenced by the fact that people continue to not use them.

Editing the Data in a GridView

In addition to deleting a GridView's underlying data, another common need is to allow end users to edit the data displayed in a GridView. With ASP.NET 1.x's DataGrid control, editing the data is certainly possible, but requires creating three event handlers and writing a dozen or so lines of code. With the GridView and ASP.NET 2.0, it is possible to create an editable GridView without writing a single line of code! All of the necessary functionality is encapsulated within the GridView.

The GridView allows editing on a row-by-row basis. An editable GridView contains an additional column with an Edit button in each row. When the end user clicks on an Edit button that row becomes editable, causing the Edit button to change to Update and Cancel buttons and the other columns to become TextBoxes. The end user can then update one or more column values and click Update to save their changes.

Using ASP.NET 3.5's ListView and DataPager Controls: Displaying Data with the ListView

Prior to ASP.NET 3.5, developers who needed to display a set of records could choose between the GridView, DataList, and Repeater controls. The GridView provides rich data features, but has a very boxy layout; the DataList and Repeater allow for a more flexible layout, but lack the "point and click" data features found in the GridView, DetailsView, and FormView controls. The ListView bridges the gap between layout flexibility and built-in data features.

This article, the first in a series of articles on the ListView and DataPager controls, looks at the ListView's many available templates and illustrates how to display data. Read on to learn more!

Dynamic Data Templates in GridView ASP.NET 3.5

At a high level, Dynamic Data Templates can be seen as a system to very quickly build up a User Interface linked with the relevant data model, immediately enabling you to perform CRUD operations (Create, Read, Update, Delete) on the database using the specified data source. They provide a powerful method for building up these kinds of applications, and I'm going to focus on an overview of what Dynamic Data Templates actually are, and a few ways of customizing them to suit industry needs.

jQuery: Styling DropDownList Alternating Items (Rows)

In the following example, I will show how you can style any asp:dropdownlist very easily.

The example demonstrates how you can change alternating row items background color, using the fadeTo() to add a nice touch in the dropdownlist. You can change alt rows with a couple lines.
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