DatagridView双语头

时间:2011-07-12 15:41:40

标签: asp.net

我需要在我的网站上支持2种语言。 在每个列标题上设置正确语言的正确方法是哪种? 我不想使用列索引来访问它。我想循环所有列,并为每个列获取正确的文本,通过它的名称或缓存中的其他键。

使用框架4.0,asp.net,c#。

感谢。

2 个答案:

答案 0 :(得分:0)

我猜你在循环列标题时需要反向查找本地化的标题文本。

Here's a way to reverse look up localized string.

答案 1 :(得分:0)

我的意思是这样的:

        if (ctl is GridView)
        {
            GridView oGrid = (GridView)ctl;
            foreach (DataControlField oClm in oGrid.Columns)
            {
                string str = string.Empty;

                str = frm.Page.ToString().Replace("ASP.", "").Replace("_aspx", "") + "_" + ctl.ID.ToString() + "_" + oClm.HeaderText.Replace(" ", "");
                Dr = DsGuiText.Tables[0].Select("Language = '" + sLang + "' And Key = '" + str + "'");
                if (Dr.Length > 0)
                {
                    oClm.HeaderText = Dr[0]["Value"].ToString();
                }

            }
        }