Solved

Binding to dropdownlist inside datagrid

Posted on 2004-09-08
1
780 Views
Last Modified: 2012-06-27
How do I bind data to a dropdownlist INSIDE a datagrid control?
0
Comment
Question by:bme2you
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 35

Accepted Solution

by:
YZlat earned 125 total points
ID: 12009530
create a separate binding function for example:

Public Function BindState()
        Dim Reader As OleDbDataReader
        Dim sql,strConn As String
      strConn="Your connection string here"
        sql = "SELECT Field1 FROM Table1"
      Dim Conn As OleDbConnection
       Conn = New OleDbConnection(strConn)
        Try
                  Conn.Open()
      Catch ex as Exception
               ''handle your exception
      End Try
        Dim Cmd As OleDbCommand = New OleDbCommand(sql, Conn)
       
        Reader = Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

        Return Reader
    End Function

Then call this function from .aspx file from dropdown Item Template:

<asp:TemplateColumn HeaderText="My header">
                                    <ItemTemplate>
                                          <asp:DropDownList id=Dropdownlist1 runat="server" DataMember="Table1" Width="150px" DataValueField="FieldID" DataTextField="Field1" DataSource="<%# BindState() %>">
                                          </asp:DropDownList>
                                    </ItemTemplate>
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Query still returning duplicates 5 58
If condition on Html with Asp 11 48
Asp in script 6 51
Designing forms 3 69
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question