How to limit the text and display full text with Read More button in grid view
DataTable table=new DataTable(); //GridView1.DataSource = table; string str2 = "select id,title,description from tbl_event order by id desc"; obj.ds = obj.ret_ds(str2); GridView1.DataSource = obj.ds; GridView1.DataBind(); int i = 0; foreach (DataRow row in table.Rows) { string x = row["description"].ToString(); if (x.Length > 10) { GridView1.Rows[i].Cells[0].Text = x.Substring(0, 10) + "<a href=EventDetail.aspx>Read More </a>"; } i++; if (i >= table.Rows.Count) { return; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)