programmher
asked on
How do I hide a datagrid when the page loads?
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
My code behind
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>
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;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.Checke d);
}
In the Page_Load, it would be something like this:
protected void Page_Load(object sender, EventArgs e)
{
gvAuthors.Visible = (ShowHideSecondGrid.Checke
}
ASKER