0

I have a gridview with the following code:

<asp:TemplateField HeaderText="Column1">     
    <EditItemTemplate>         
        <asp:Label ID="Label1" runat="server" Text='<%# Bind("Column1") %>'></asp:Label  
    </EditItemTemplate>     
    <ItemTemplate>
        <asp:DropDownList ID="DropDownList1" runat="server" Width="125px">         
    </asp:DropDownList>     
    </ItemTemplate> 
    </asp:TemplateField> 

I want to bind a sql statement to populate the dropdownlist...

select Column1 from Table1 would I do this through the code behind?

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
developthestars
  • 185
  • 1
  • 12
  • 27

1 Answers1

0

You can do it in the codebehind if you wish, or, if it applies to your situation, you can use the ObjectDataSource web server control.

More reading: ObjectDataSource Web Server Control Overview

Here's an example on how to bind the ObjectDataSource to your dropdown: asp.net ObjectDataSource example: how to populate DropDownList

Jeremy
  • 8,902
  • 2
  • 36
  • 44