Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Binding to dropdownlist inside datagrid

Posted on 2004-09-08
1
Medium Priority
?
787 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 375 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

610 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