DataGrid中取HyperLinkColumn列的值,处理DataGrid中绑定的特殊字符

DataGrid中取HyperLinkColumn列的值.

 /// <summary>

    /// 对datagrid中标签进行编码,处理特殊字符

    /// </summary>

    /// <param name="gvGrid">DataGrid</param>

    public void EncodeCurrentDataGrid(DataGrid gvGrid)

    {

        foreach (DataGridItem dgi in gvGrid.Items)

        {

            for (int i = 1; i < dgi.Cells.Count; i++)

            {

                if (gvGrid.Columns[i] is BoundColumn)

                {

                    dgi.Cells[i].Text = StringLang.getEmptyString(dgi.Cells[i].Text);

                }

                if (gvGrid.Columns[i] is HyperLinkColumn)

                {

                    ((HyperLink)dgi.Cells[i].Controls[0]).Text = StringLang.getEmptyString(((HyperLink)dgi.Cells[i].Controls[0]).Text);

                }

            }

        }

    }
处理DataGrid中特殊字符

 

///处理特殊字符对object类型文本进行编码

public static string getEmptyString(object obj)

{

    string str;

    try

    {

        if (obj == null)

        {

            return "";

        }

        str = WebLang.dvHTMLEncode(obj.ToString());

    }

    catch (SystemException exception)

    {

        throw exception;

    }

    return str;

}

 

 

你可能感兴趣的:(datagrid)