tags:

views:

31

answers:

2

I am working in asp.net 3.5 and have some issue of update panel.I have some html content and Formview control in a page. I want to hide the html content when there is no data in the Formview and to show when there is data in the Formview control. My Formview control is in the updatepanel and it it is bind to SqlDataSource and Formview binds on some criteria. If somebody know how to solve this issue then please help me.

Thanks & Regards

Ashok

A: 

If you want the HTML content to be hidden after an Ajax postback, it will need to be in an UpdatePanel, either the same one your FormView is in, or a separate one.

If it's in a separate one, you'll need some way of forcing it to update when the FormView updates. You can either do this in some code-behind, calling the Update() method of the UpdatePanel, or by adding an AsyncPostBackTrigger to the UpdatePanel containing the HTML, maybe using the DataBound event of the FormView.

Also, to easily hide the HTML content, put it in a Panel, and use the Visible property.

An example of the trigger:

<asp:UpdatePanel ID="updatePanel" ... runat="server">
   <ContentTemplate>
      ...
   </ContentTemplate>
   <Triggers>
      <asp:AsyncPostBackTrigger ControlID="formViewId" EventName="DataBound" />
   </Triggers>
</asp:UpdatePanel>
Graham Clark
Graham Thanks for reply. But My issue is like : I have a form having Dropdown , Grid View, FormView and list view on the page and all are in there separate Update panel and some html like div is also on the page but the div is not in any update panel. Now on the change of drop down or on the selected index change event of grid view the other controls List view and Form view are populated. Now i want is if any event occurs (mentioned above) then i want to check if the control List view have data then i want to show some html text on the page otherwise it will be hidden.
ashok
Ok, so it seems like you need to put your HTML in a Panel, all inside a new UpdatePanel, and create a server-side event handler to handle the SelectedIndexChanged events. In here, check the ListView, and set the `Visible` property of the Panel the HTML is in.
Graham Clark
A: 

This issue simply resolved using the putting all the html content in the Updatepanels and on UpdatePanel_preRender event of Updatepanels check that if Gridview has data then show html content otherwise hide

ashok