Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I declared my template as follows

<EditItemTemplate>
    <asp:DropDownList ID="ddlYear" runat="server" 
                      DataSource='<%#GetYears() %>' 
                      DataTextField="year" 
                      DataValueField="year" />
</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 Years 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.
Posted
Updated 7-Dec-10 1:55am
v4

Hi see this[^]

Link 2[^]
 
Share this answer
 
v2
Comments
Dalek Dave 7-Dec-10 9:27am    
Good Link.
What you have done is correct.

But from the optimization point of view I think that every time when the row binding will occur, your function "GetYears" will be executed.

What the best I can think of is, make a property (store value in viewstate) which gets initialized at page load with function "GetYears()" and then use it to fill the drop down. This will save your function call each time. Plus do a validation at page load to call GetYears only when your property is empty.

Hope that helps. :)
 
Share this answer
 
Comments
Dalek Dave 7-Dec-10 9:27am    
Good hint.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900