I have a DataTable
that contains 3 fields: ACount
, BCount
and DCount
. If ACount < 0
then I need to displa
This has worked for me.... I must be misunderstanding something so I had to replace angled brackets with [ or ] for the ASP so just be aware of that.
[asp:TemplateField runat="server" HeaderText="Header"]
[ItemTemplate]
[asp:Label ID="theLabel" runat="server" Text='[%# Eval("DataSource").ToString()
%]'][/asp:Label]
[/ItemTemplate]
[/asp:TemplateField]
protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label newLabel = (Label)e.Row.FindControl("theLabel");
if (newLabel.Text.Length > 20) //20 is cutoff length
{
newLabel.Text = lbl.Text.Substring(0, 20);
newLabel.Text += "...";
}
}
}