A
aammi
I am tired of this error and now writing a post.
My Web application has two pages.
Page one has drop down list which redirect the page to another page . where I am going to load the usercontrol dynamically according to the choice of the user.
protected void ddlViewReport_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddlViewReport.SelectedIndex == 1)
{
Session["ReportType"] = ddlViewReport.SelectedIndex;
Response.Redirect("RepReportingPage.aspx");
int crosspagevalue = ddlViewReport.SelectedIndex;
}
if (ddlViewReport.SelectedIndex == 2)
{
Session["ReportType"] = ddlViewReport.SelectedIndex;
Response.Redirect("RepReportingPage.aspx");
}
}
that code redirect me to the another page "RepRepoortingpage.aspx. There the user contol should load. It is loading but when I add the Textbox or the gridview, it throws and error. "Control 'ctl02_GridView1' of type 'GridView' must be placed inside a form tag with runat=server"
I tried many things but it still not working. here is the code for the other page where I am loading the control dynamically.
public partial class RepReportingPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int whichControl = Convert.ToInt32(Session["ReportType"]);
if (whichControl == 1)
{
Control UCReportExpense = LoadControl("WebUserControl2.ascx");
PlaceHolder1.Controls.Add(UCReportExpense);
}
else
{
Response.Write("would put seocond user control after solving the problem");
}
}
}
Now any help here please .
My Web application has two pages.
Page one has drop down list which redirect the page to another page . where I am going to load the usercontrol dynamically according to the choice of the user.
protected void ddlViewReport_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddlViewReport.SelectedIndex == 1)
{
Session["ReportType"] = ddlViewReport.SelectedIndex;
Response.Redirect("RepReportingPage.aspx");
int crosspagevalue = ddlViewReport.SelectedIndex;
}
if (ddlViewReport.SelectedIndex == 2)
{
Session["ReportType"] = ddlViewReport.SelectedIndex;
Response.Redirect("RepReportingPage.aspx");
}
}
that code redirect me to the another page "RepRepoortingpage.aspx. There the user contol should load. It is loading but when I add the Textbox or the gridview, it throws and error. "Control 'ctl02_GridView1' of type 'GridView' must be placed inside a form tag with runat=server"
I tried many things but it still not working. here is the code for the other page where I am loading the control dynamically.
public partial class RepReportingPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int whichControl = Convert.ToInt32(Session["ReportType"]);
if (whichControl == 1)
{
Control UCReportExpense = LoadControl("WebUserControl2.ascx");
PlaceHolder1.Controls.Add(UCReportExpense);
}
else
{
Response.Write("would put seocond user control after solving the problem");
}
}
}
Now any help here please .