Solved

How do I hide a datagrid when the page loads?

Posted on 2014-01-15
3
395 Views
Last Modified: 2014-01-16
I have a page that has two data grids.  One displays authors and when the author is selected all of the books written by that author are displayed on the same page.  The user can then select all or some of the books and submit a request for those selected books to be pulled by the librarian.

My question is how do I get the second grid to be hidden when the page loads?  The client want to be able to collapse and expand/hide or show the second grid.

My code for the grids
     <div>
        <asp:GridView runat="server" ID="gvBooks" DataSourceID="Books_ds" />
        <asp:GridView runat="server" ID="gAuthorss" DataSourceID="Authors_ds" AutoGenerateSelectButton="true" DataKeyNames="AuthorName" />     
    </div>

Open in new window


My code  behind
    public static List<AuthorSelection> GetAuthorList()
    {
        List<AuthorSelection> Authors = new List<AuthorSelection>();
        SearchResultCollection src = ds.FindAll();

        foreach (SearchResult sr in src)
        {
            if (!sr.Properties.Contains("msexchhidefromaddresslists") || (sr.Properties["msexchhidefromaddresslists"][0].ToString() != "True"))
            {
                AuthorSelection auths = new AuthorSelection();
                if (sr.Properties.Contains("authorname")) gs._name = sr.Properties["authorname"][0].ToString();
                if (sr.Properties.Contains("displayedauthname")) gs._display = sr.Properties["displayedauthname"][0].ToString();
        Authors.Add(gs);
            }

        }
        return Authors;

Open in new window

0
Comment
Question by:programmher
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 250 total points
ID: 39785288
I would think that you need some way to store the state of the show/hide for the second grid.  In the Page_Load event handler, you could then set the GridView.Visible property to the current state for the show/hide.
0
 

Author Comment

by:programmher
ID: 39785309
Thanks - that is what I was trying but was unsucessful.  I will search some more for the actual code.  I am likely missing something simpe.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 39785359
You could use a ViewState variable or a CheckBox.

In the Page_Load, it would be something like this:

protected void Page_Load(object sender, EventArgs e)
{
     gvAuthors.Visible = (ShowHideSecondGrid.Checked);
}
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question