.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

Binding dropdownlist along with Heading

Posted By:      Posted Date: September 21, 2010    Points: 0   Category :ASP.Net

I need to bind a dropdownlist to multiple column along with the column heading.. the heading should be unselectable

something similar to this

Each group are in differnet tables..

How can i implement this

its consuming my time.. thanx 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

DropDownList to display values from Two Tables - bold sub heading and normal Text

Hello I hope I am not asking simple one.  SUPPORT SERVICES<     Computing Service    Library or Data Engineering    Civil Engineering    Electrical Engineering  I have the data to display in a DropDownList control shown as above. There is a distinct category Type(example Support Services) and Category Name i.e., Computing Services. I do not want to hard code the values into DropDownList control. I like to get the data from database to display as shown in above Table. Note that Category Type should be displayed in Bold and Category Name in normal Text. Question: In order to achieve the above, 1. How many database Tables and relationships between them  2. Query the data to display in the above format in drop down 3. how should be the code behind i.e, DataTextValue and DataValueField for DropDownList. Please provide with useful code snippets or references. Thanks,

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!

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

binding dropdownlist to datasource C#


 I have the following code in which I am trying to use a dropdownlist to update values in a gridview. I having trouble getting the datasource to bind to the dropdownlist

here is my code:

protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
                if (e.Row.RowState == DataControlRowState.Edit)
                    DropDownList DropDownList1 = new DropDownList();
                    string Query = "SELECT DISTINCT STATUS FROM VW_MSG_VIEW";
                    DataSet dt = new DataSet();
                    OracleCommand cmd1 = new OracleCommand(Query, con);
                    OracleDataAdapter sqlDa = new OracleDataAdapter(cmd1);
                    DropDownList ddl = (DropDownList)e.Row.FindControl("DropDownList1");
                    ddl.DataSource = dt;
                    ddl.DataValueField = "STATUS";
                    ddl.DataTextField = "STATUS";

I am getting nullreference exception on line ddl.DataSource = dt;


Thanks for any help

binding xml to dropdownlist declaratively


i have xml file like this.


<?xml version="1.0" encoding="utf-8" ?>
    <Name>My State 1</Name>
    <Name>My State 2</Name>
      <Name>My State 3</Name>
      <Name>My State 4</Name>
      <Name>My State 5</Name>

and an aspx file


<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <form id="form1" runat="server">

Model Binding with DropDownList


Hello again -

I seem to be having issues with posting forms with DropDownLists. I've looked all over the net and tried various solutions, but none seem to work for me.

I'm getting the following error: The parameter conversion from type 'System.String' to type 'Models.Organization' failed because no type converter can convert between these types.

Here's my ViewModel:

    Public Class RegistrationViewModel
        Public Property User() As User
                Return _user
            End Get
            Set(ByVal value As User)
                _user = value
            End Set
        End Property
        Private _user As User

        Public Property ConfirmPassword() As String
                Return _confirmPassword
            End Get
            Set(ByVal value As String)
                _confirmPassword = value
            End Set
        End Property
        Private _confirmPassword As String

        Public Property Profile() As Profile
                Return _profile
            End Get
            Set(ByVal value As Profile)
                _profile = value
            End Set
        End Property
        Private _profile As Profile

        Public Property PhoneNumber() As PhoneNumber
                Return _phoneNumber

DropDownList Binding - Ways to Increase Speed?


I have a gridview that displays query results on a reporting page for a "home-grown" CRM application. From the gridview, a link can be clicked which opens a modal window that contains an iframe linked to a "details" page where record specific info can be viewed/altered. On the details page there are 10 or so dropdownlists (ddls) that are bound every time the page is called. The ddls are bound using a method similar to the example below. I am looking for a way top speed things up a bit. The details page could be called 10-20 times in one session and every time the page loads these ddls have to be bound from the same methods but for different records. What are some options for speeding up the load time for this page??

if (!Page.IsPostBack)
     //call initial processes
     //and a few more method calls for binding ddls....

private void GetModel()
        string connString = ConfigurationManager.ConnectionStrings["processes"].ConnectionString;
        string cmdString = "SELECT Model, Type + '§' + CAST(ID AS NVARCHAR) + '§' + Factory AS Vals FROM Machines WHERE (Active = 'True')" +
                           "ORDER BY Mod

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.

Binding the multiple drop down boxes in GridView using JQuery in ASP.NET

Here is the code for binding the multiple drop down boxes in GridView using JQuery in ASP.NET

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.

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.

Working with DropDownList and ListBox Controls in ASP.NET

"In my application i am using dropdownlist to display all categories from a table. When the user clicks this control I display all records in that category. Category table also contains column called color.

I wanted display some categories in dropdown list different color and others in different color using ASP.NET."-Anonymous

ASP.NET DropDownList Web Control, Part 1

Anybody with much experience in ASP has written an include file function for populating the contents of a SELECT dropdown list with entries from a database. Some of the more advanced users have even gone so far as to add caching to their function to reduce database hits for these rarely changing menu options. Naturally, these same techniques are going to be used with ASP.NET, but with a new programming object model. ASP.NET provides a web control, the DropDownList, which can be used for the same purposes as our custom built SELECT tag from Classic ASP.

Declaring a DropDownList in ASP .Net

A DropDownList is also commonly known as combo box. It can contain multiple data members, but unlike a normal list box the users can choose only one value from this control. Though the functionality of this DropDownList is much like a Single Row Select List Box, a DropDownList can save a lot of GUI space as it is rendered on a Single line and is expanded only when the user clicks on the Control

Multiple Column Dropdownlist for the ASP.NET DataGrid

Based on my previous control "Multiple Column DropDownList for ASP.NET", I received many emails asking for the same control to be used in the DataGrid for web applications. Here we go.. This control can be used as the regular MS DropDownList in the DataGrid and also as a regular dropdownlist. It has all the properties, like DataTextField, DataValueField, DataSource, SelectedIndex etc. The download file contains the samples both in VB.NET and C#. In this sample, I have used the Northwind database of SQL Server.

ASP.NET Multiple Selection DropDownList with AJAX HoverMenuExtender

Recently, I was looking for a multiple selection dropdownlist control for my new project. After spending some time researching for it, I decided to put together all my finding in one web user control. This web user control consists of an ASP.NET AJAX HoverMenuExtender, JavaScript, StyleSheet and CheckBoxListExCtrl . The final product will work with or without a MasterPage and you can drag and drop more than one instances of the control on to the page.
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