<< Click to Display Table of Contents >> GridView - trocando texto de um HyperLinkField em runtime |
![]() ![]() ![]() |
Enter topic text here.
Default.aspx
<asp:GridView ID="Grid" runat="server" OnRowDataBound="Grid_RowDataBound"/>
Default.aspx.cs
protected void Grid_RowDataBound(object sender, GridViewRowEventArgs e)
{
// quando montar as linhas do tipo DADOS
if (e.Row.RowType == DataControlRowType.DataRow)
{
// titulo, se maior que 70 chars ele "resume"
string titulo = DataBinder.Eval(e.Row.DataItem, "nm_tarefa").ToString();
if (titulo.Length > 70)
((HyperLink)e.Row.Cells[COLUNA_DESCRICAO].Controls[0]).Text = titulo.Substring(0, 67) + "(...)";
}
}