Search code examples
asp.netmodalpopupextender

Modal Popup Extender: Fetch data from database then bind it to the label in the modalpopupextender


I've a problem with ModalPopupExtender. I have put a label in ModalPopupExtender and trying to bind label with the value from database. When I am debugging, the value is showing on the label's text (ie there is no database error), but it is not displaying when the popup window is shown.

Can any one help me please ????????

Here's my code

Code on html

<asp:Panel ID="PopupPnl" runat="server">
  <table style="width:100%;"> 
    <tr>
      <td >
         <asp:Label ID="Label2" runat="server" 
                    Text="View Description" >
         </asp:Label>
      </td>
    </tr>
    <tr>
      <td >
         <asp:Label ID="label_Descrption" runat="server" >
         </asp:Label>
      </td>
   </tr>
   <tr style="background-color:White;">
      <td >
         <asp:Button ID="btnExit" runat="server" Text="Exit"/>
      </td>
   </tr>  
  </table> 
 </asp:Panel>
<asp:Button ID="btnShowPopup" runat="server" 
            style="display:none;"/>
<cc1:ModalPopupExtender ID="ModalPopupExtender2" runat="server" 
                        TargetControlID="btnShowPopup" 
                        PopupControlID="PopupPnl" 
                        CancelControlID="btnExit" 
                        BackgroundCssClass="ModalPopupBG" >

</cc1:ModalPopupExtender>

Code on c#

 protected void lbn_Template_Click(object sender, EventArgs e)
{
    util_Category objUtilCategory = new util_Category();
    cl_Category objClCategory = new cl_Category();
    if (ddlSubCategory.SelectedItem.Text != "--Select A SubCategory--")
    {
        objClCategory.CategoryId = Convert.ToInt32(ddlSubCategory.SelectedValue);
        Label lbl = (Label)PopupPnl.FindControl("label_Descrption");

        label_Descrption.Text = objUtilCategory.GetATemplate(objClCategory);
        ModalPopupExtender2.Show();
    }
}

Solution

  • You need to place the Panel which contains the label_Description inside UpdatePanel.