Please copy this below code in you code behind and make changes according to
your requirement.
protected void GrdEastablishment_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label objlblans = new Label();
Label objlblsubject = new Label();
objlblans = (Label)e.Row.FindControl("lbledit");
objlblsubject = (Label)e.Row.FindControl("lblsubject");
string strans = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "sDetail"));
if (strans != "")
{
string ans = (string)DataBinder.Eval(e.Row.DataItem, "sDetail");
if (ans.Length > 28)
{
objlblans.Text = ans.ToString().Substring(0, 28).ToString() + "...";
}
else
{
objlblans.Text = ans.ToString();
}
}
else
{
objlblans.Text = "No Text";
}
string strsubject = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "sSubject"));
if (strsubject != "")
{
string ans = (string)DataBinder.Eval(e.Row.DataItem, "sSubject");
if (ans.Length > 15)
{
objlblsubject.Text = ans.ToString().Substring(0, 15).ToString() + "...";
}
else
{
objlblsubject.Text = ans.ToString();
}
}
else
{
objlblsubject.Text = "No Text";
}
}
}
No comments :
Post a Comment