Developer
Developer

Reputation: 8646

How can i bind data to a dropdown in the gridview which is an EditItemTemplate

I declared my template as follows

    <EditItemTemplate>  
               <asp:DropDownList ID="ddlYear" runat="server" DataSource='<%#GetYears() %>' DataTextField="year" DataValueField="year"></asp:DropDownList>  
           </EditItemTemplate>

I need to bind the data from the function i used GetYears() i don't know how to function it can any one help me

I need the data for example name to be loaded in dropdown when i click on Edit of gridview is it the correct way or is there any best way to do this

Upvotes: 0

Views: 1445

Answers (2)

sam
sam

Reputation: 685

in the code behind you can find dropdown using findcontrol method on the click of edit link and can bind easily.

Upvotes: 1

TBohnen.jnr
TBohnen.jnr

Reputation: 5129

You could create an objectDatasource on the page and then set the datasourceid to that objectDataSource. Then you can create your POCO class Look at this link for more info on objectdatasource http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/data/objectdatasource.aspx

Upvotes: 0

Related Questions