开发者

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

开发者 https://www.devze.com 2023-01-29 10:32 出处:网络
I declared my template as follows <EditItemTemplate> <asp:DropDownList ID=\"ddlYear\" runat=\"server\" DataSource=\'<%#GetYears() %>\' DataTextField=\"year\" DataValueField=\"year\">

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 exa开发者_开发问答mple 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


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消