How to limit label string length in GridView with Read More link?

前端 未结 3 579
孤城傲影
孤城傲影 2021-01-14 23:36

Currently I used like this...


 
      

        
3条回答
  •  梦谈多话
    2021-01-15 00:04

    Add an invisible HtmlAnchor control after the Label. Try something like,

    
     
          
          
          [Read More]
     
    
    
    if(strDesc.Length > length)
    {
        var anchor = ((Label)Desc).NamingContainer.FindControl("aReadMore");
        anchor.Visible = true;
        return strDesc.ToString().Substring(0, length) + "...";
    }
    

提交回复
热议问题