forum

Home / DeveloperSection / Forums / How to display data in gridview on click?

How to display data in gridview on click?

Anonymous User 1911 13-Nov-2014

I have a gridview that becomes quite long with some information that could be somewhat hidden.

Here's my asp:

<asp:GridView ID="gvLogBody" runat="server" CssClass="Grid" AllowPaging="true" AllowSorting="true" PageSize="10" AutoGenerateColumns="true">
</asp:GridView>

And here's my code behind:

DataSet ds = new DataSet();
ds.Tables.Add("LogBody");
ds.Tables["LogBody"].Columns.Add("timeStamp");
ds.Tables["LogBody"].Columns.Add("name");
ds.Tables["LogBody"].Columns.Add("message");
foreach (LogObject l in logLines)
{
    ds.Tables["LogBody"].Rows.Add(l.TimeStamp, l.Name, l.Message);
}
gvLogBody.DataSource = ds.Tables["LogBody"].DefaultView;
gvLogBody.DataBind();

This gives me a gridview that looks like this: ____________________________________________________________________________________________

|timeStamp|                      name                     |            message             |

+---------+-----------------------------------------------+--------------------------------+

|01-01-01 | someLongAndQuiteUnnecesaryNameThatIWishToHide | someMessageThatIsMoreImportant |

+---------+-----------------------------------------------+--------------------------------+

What I want is something like this:

_________________________________________________________

|timeStamp|    name     |            message             |

+---------+-------------+--------------------------------+

|01-01-01 | clickToShow | someMessageThatIsMoreImportant |

+---------+-------------+--------------------------------+

And once the user clicks the text, it expands / opens a popup or something.

How can this be done?


Updated on 14-Nov-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By