I'd like to localize my aspx-page.
This should include dynamically created LinkButtons in a GridView inside of InstantiateIN
(amendment 1: implementation of the System.Web.UI.ITemplate.InstantiateIN method to manipulate the appearance of a GridView)
(amendment 2: first six lines of code added to better indicate location of other code)
But inside InstantiateIN I cannot use (see) the method GetLocalResourceObject
Solution: use a Session-Variable
Question: Why can't I use GetLocalResourceObject inside InstantiateIN?
the following happens inside InstantiateIN
public class DynamicTemplateGridViewSearch : ITemplate
{
public void InstantiateIn(System.Web.UI.Control Container)
{
switch (ItemType)
{
case ListItemType.Item:
switch (InfoType)
{
case "Command":
{
LinkButton search_button = new LinkButton();
search_button.ID = "search";
search_button.CommandName = "Edit";
//following line does not work. Error is:
//The name 'GetLocalResourceObject' does not exist in the current context
search_button.Text = GetLocalResourceObject("SearchButtonResource1.Text").ToString();
//so I have to create a Session-String in Page_Load
//which is referenced here
search_button.Text = (string)new Page().Session["SearchText"]; // "Search";
search_button.Click += new EventHandler(search_button_Click);
Container.Controls.Add(search_button);