Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends.
I am using a datalist in which their is a panel.
I want to hide the panel when a value in the database column is false and show the panel when a value in the database column is true.

Please help
Posted
Comments
Sandeep Mewara 8-May-12 9:30am    
And what is the issue with it? Where are you stuck?

1 solution

Use item data bound event in datalist for such functionality. You can use a label variable or datakey to check the value for the conditional column depending on whether to show that column or not.

C#
void Item_Bound(Object sender, DataListItemEventArgs e)
     {

        if (e.Item.ItemType == ListItemType.Item ||
            e.Item.ItemType == ListItemType.AlternatingItem)
        {
           string strID = DataGrid1.DataKeys[e.Item.ItemIndex].ToString();
           // Retrieve the Panel control in the current DataListItem.
           Panel toBeOrNotToBe = (Label)e.Item.FindControl("myPanel");

           if(strID=="something")
           // make it hidden here; 

        }

     }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900