Wednesday, March 28, 2012

extending Gridview in Ajax

Hi,I'm binding a table to a gridview and it's all working fine. but what I would like to do is in one of the cells where the data bit big (a large paragraph) I would the cell to be able to show only the first few words than if the use move the mouse over the cell the whole paragraph will be displayed or the cell will expand or something.So, is there a way to extend the Gridview with Ajax allowing it to do that Or is there a control that I could be extended and add in a TemplateField that could do that!!!? Thanks

try this code on your rowbound event

protectedvoid GridView1_RowDataBound(object sender,GridViewRowEventArgs e)

{

if (e.Row.RowIndex != -1)

{

e.Row.Cells[4].ToolTip = e.Row.Cells[4].Text;

e.Row.Cells[4].Text = e.Row.Cells[4].Text.Substring(0, 15);

}

}

i wrap the text of column 4 th to only 15 character and showing the tooltip as a whole text which was the actual value of that column


You can integrate something like this into your grid:http://www.cssplay.co.uk/menu/more.html

-Damien


That's actually very nice thanks Mahadeo.


string strCount= e.Row.Cells[4].Text ;

if(strCount.Length > 16)

{

e.Row.Cells[4].Text = stringFormat("{0}{1}",strCount.SubString(0,15),"...")

}

No comments:

Post a Comment