TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Terry
NA
148
0
Hide ListView on Button Click
Mar 23 2015 12:56 PM
In my asp.net 4.5 webforms, I am trying to hide a ListView on a button click. have a LinkButton to Show/Hide the LinkView. But somw how the ListView's Visible state is not changed only, it's always visible. Here's my code :
<asp:LinkButton runat="server" Visible="true" ID="collapseFloorList" Text="Hide" OnClick="collapseFloorList_Click"></asp:LinkButton>
<asp:Panel ID="floorPanel" runat="server" >
<asp:ListView runat="server" ID="floorList"
ItemType="VincitoreCRMApplication.Models.FloorPattern"
UpdateMethod="floorList_UpdateItem" DeleteMethod="floorList_DeleteItem"
SelectMethod="floorList_GetData" DataKeyNames="FloorPatternId"
Visible='<%# ShowFloorList %>' >
In Code behind, I have a Property in PAge named ShowFloorList :
public bool ShowFloorList { get; set; }
protected void Page_Init(object sender, EventArgs e)
{
if (!IsPostBack)
{
ShowFloorList = true;
}
}
protected void collapseFloorList_Click(object sender, EventArgs e)
{
System.Diagnostics.Debug.WriteLine("COLLAPSE FLOOR BTN Click Floor List State = " + floorList.Visible + " BTN TEXT = " + collapseFloorList.Text );
if (collapseFloorList.Text == "Hide") // Requesting to Hide i.e. Visible to make false
{
System.Diagnostics.Debug.WriteLine("INSIDE HIDE");
ShowFloorList = false;
System.Diagnostics.Debug.WriteLine("SHOWFLOOR LIST = " + ShowFloorList);
}
else
ShowFloorList = true;
/*
if (ShowFloorList == false)
{
collapseFloorList.Text = "Show";
ShowFloorList = false;
//floorPanel.Visible = false;
//floorList.Visible = false;
}
{
collapseFloorList.Text = "Hide";
ShowFloorList = true;
floorPanel.Visible = true;
//floorList.Visible = true;
} */
}
Logs on Execution :
COLLAPSE FLOOR BTN Click Floor List State = True BTN TEXT = Hide
INSIDE HIDE
SHOWFLOOR LIST = False
I tried making the floorLsit directly visible to false, adding it in a panel & making panel visible, and now alos thru property but Nothing works. Also tried changing ListButton to asp:Button, but yet same results. The button click event is fired, the value of ShowFloorList property is being changed to false, but the visibility of ListView doesn't change. It is visible always.
Can you tell me why am not able to hide the Listview ??
Any help is highly appreciated.
Thanks
Reply
Answers (
6
)
MVC Questions
Access a Control from EditItemTemplate and update a Property