I have got one user control, I am loading this user control from a parent page when the button clicked ..
In user control I have got one drop downlist and grid view , both data is loading form DB in page load method ......
but in parent page when I click on the button to load the user control, I am able to see only one drop down with no loaded values in it(normally it is loaded with values ) and not able to see the grid view as well ....
and this is my code ..on parent page
<%@ Page Language="C#" MasterPageFile="~/MasterPages/template.master" AutoEventWireup="true" CodeFile="ViewCertificateMaster.aspx.cs" Inherits="Pages_ViewCertificateMaster" %>
<%@ Register Src="../Controls/one.ascx" TagPrefix="uc1" TagName="one" %>
and in code behind file
protected void btnShow_OnClick(object sender, EventArgs e)
{
int selectedItem = ddlProductType.SelectedIndex;
switch (selectedItem)
{
case 0:
UserControl myUsrControl = (UserControl)Page.LoadControl("../Controls/one.ascx");
divViewMyCerts.Controls.Add(myUsrControl);
divViewMyCerts.Visible = true;
break;
....................
..................
..................
code
in one.ascx code behind file ...
protected void Page_Load(object sender, EventArgs e)
{
string remoteUser = ((UserInfo)Session["USER_INFO"]).GetUserEmail();
intAcctId = ((UserInfo)Session["USER_INFO"]).GetUserAcctId();
objCert = new Certificate();
if (!IsPostBack)
{
.............
here I am binding the grid view and drop down list values from DB
...............
...............
Would any one please help on this why I am getting empty dropdown list and not able to see the grid view as well ....
many thanks in advance
Because IsPostBack will be true in Page_Load of the one.ascx. Since the control is being added at btnShow_OnClick event at the page and the IsPostBack is true here. Check the value of IsPostBack in one.ascx in your code.
See the definition of IsPostBack of a user control. Which is
"Summary: Gets a value indicating whether the user control is being loaded in response to a client postback, or if it is being loaded and accessed for the first time.
Returns: true if the user control is being loaded in response to a client postback; otherwise, false."
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.