views:

389

answers:

3

One of gridview's column is a "Content" column that can have few lines of text (it can be literal, textbox or label ).

In "default" mode i want it to show only the first line and a link button: "(more)" or "(read)".

Clicking on this link should expand the column and display full content.

What is the best way to do this?

A: 

Selecting first 10 characters of content text and using it as your link's text is better aproach. This will reduce size of data that retrieved from database like that :

SELECT ContentId, SUBSTRING(Content, 0, 10) AS Content
FROM ContentTable;

Then you can use template column for this column that includes a label and a link. Lbel for the description text, link for the details.

<asp:TemplateColumn>

   <ItemTemplate>
      <asp:Label
           Text='<%# Eval("Content") %>'
           runat="server"/>
      <a href='<%# Eval("ContentId", "contentdetails.aspx?id={0}") %>'>More</a>
   </ItemTemplate>

</asp:TemplateColumn>
Canavar
I am already filling gridview via ObjectDataSource and use '<%# Eval("Content") %>' to get the full content.Can I trim the content before it's being inserted?
markiz
Then you have a property for content ? you can trim content at the getter of the property.
Canavar
but clicking on the link won't expand the row...
markiz
A: 

try this. http://mosesofegypt.net/post/BuildingjQueryAndASPNetAJAXEnabledControlsjQueryCollapsiblePanelExtenderPart2.aspx

I don't want to use ajax.
markiz
I believe you can do it with out ajax too.. if that looks similar to what you want.
it's not exactly what i need
markiz