V
Vadivel Kumar
I have a webform and in its load event, i'm binding values taken
from the database in more than one data list which is embedded
in a placeholder.
When, debug the code it seems the page_load event
called two times while loading the page.
I have pasted the code below.
Plz help me.
Vadivel Kumar
The CODE Starts here
***************************
if(!IsPostBack)
{
categories = new Categories.Biz.Categories("");
ModuleSelector m = (ModuleSelector) Page.FindControl("ModuleSelector1");
m.SelectedModule = "COMPANIES";
if(Request.QueryString.Count > 0)
{
if(Request.QueryString["id"].ToString().StartsWith(@"\"))
{
string hBronze = Utils.GetBronzeTemplate();
Response.Write(hBronze);
}
if(Request.QueryString["id"].ToString().StartsWith("C"))
{
Add.Visible = false;
Inquire.Visible = false;
phTools.Visible = false;
string nRequestedId = Request.QueryString["id"].Substring(1);
SitePath.Text = "<a href=\"#\"> Home </a> >> <a href=\"companies.aspx\">
Companies </a> >> " + getCategoryPath(nRequestedId);
Application["SitePath"] = SitePath.Text;
dlSubCategory.DataSource =
categories.getCompanySubCategories(Convert.ToInt32(nRequestedId));
dlSubCategory.DataBind();
}
if(Request.QueryString["id"].ToString().StartsWith("X"))
{
Add.Visible = true;
Inquire.Visible = true;
phTools.Visible = true;
string nRequestedId = Request.QueryString["id"].Substring(1);
SitePath.Text = Application["SitePath"] + " > " +
getSubCategoryPath(nRequestedId);
Counter1.SubcategoryId = Convert.ToInt32(nRequestedId);
dsCompanies = categories.getCompanies(Convert.ToInt32(nRequestedId));
dlCompanies.DataSource = dsCompanies;
//categories.getCompanies(Convert.ToInt32(nRequestedId));
dlCompanies.DataBind();
}
}
else
{
SitePath.Text = "<a href=\"#\">Home</a> > <a href=\"companies.aspx\">
Companies </a>";
Add.Visible = false;
Inquire.Visible = false;
phTools.Visible = false;
DataTable dtCategory = new DataTable("table1");
DataTable dtSubCat = new DataTable("table2");
dtCategory = categories.getCompanyCategories().Tables[0];
dtSubCat = categories.getCompanySubCategories().Tables[0];
DataSet dsWhole = new DataSet("Companies");
dsWhole.Tables.Add(dtCategory.Copy());
dsWhole.Tables[0].TableName = "CompanyCategory";
dsWhole.Tables.Add(dtSubCat.Copy());
dsWhole.Tables[1].TableName = "CompanySubCategory";
DataColumn dtParent = dsWhole.Tables["CompanyCategory"].Columns["CatId"];
DataColumn dtChild = dsWhole.Tables["CompanySubCategory"].Columns["CatId"];
DataRelation drPCRelation = new
DataRelation("CatSubCatRelation",dtParent,dtChild,false);
dsWhole.Relations.Add(drPCRelation);
dlCompCategory.DataSource = dsWhole.Tables["CompanyCategory"];
dlCompCategory.DataBind();
dsWhole.Dispose();
dtParent.Dispose();
dtChild.Dispose();
}
}
********************
from the database in more than one data list which is embedded
in a placeholder.
When, debug the code it seems the page_load event
called two times while loading the page.
I have pasted the code below.
Plz help me.
Vadivel Kumar
The CODE Starts here
***************************
if(!IsPostBack)
{
categories = new Categories.Biz.Categories("");
ModuleSelector m = (ModuleSelector) Page.FindControl("ModuleSelector1");
m.SelectedModule = "COMPANIES";
if(Request.QueryString.Count > 0)
{
if(Request.QueryString["id"].ToString().StartsWith(@"\"))
{
string hBronze = Utils.GetBronzeTemplate();
Response.Write(hBronze);
}
if(Request.QueryString["id"].ToString().StartsWith("C"))
{
Add.Visible = false;
Inquire.Visible = false;
phTools.Visible = false;
string nRequestedId = Request.QueryString["id"].Substring(1);
SitePath.Text = "<a href=\"#\"> Home </a> >> <a href=\"companies.aspx\">
Companies </a> >> " + getCategoryPath(nRequestedId);
Application["SitePath"] = SitePath.Text;
dlSubCategory.DataSource =
categories.getCompanySubCategories(Convert.ToInt32(nRequestedId));
dlSubCategory.DataBind();
}
if(Request.QueryString["id"].ToString().StartsWith("X"))
{
Add.Visible = true;
Inquire.Visible = true;
phTools.Visible = true;
string nRequestedId = Request.QueryString["id"].Substring(1);
SitePath.Text = Application["SitePath"] + " > " +
getSubCategoryPath(nRequestedId);
Counter1.SubcategoryId = Convert.ToInt32(nRequestedId);
dsCompanies = categories.getCompanies(Convert.ToInt32(nRequestedId));
dlCompanies.DataSource = dsCompanies;
//categories.getCompanies(Convert.ToInt32(nRequestedId));
dlCompanies.DataBind();
}
}
else
{
SitePath.Text = "<a href=\"#\">Home</a> > <a href=\"companies.aspx\">
Companies </a>";
Add.Visible = false;
Inquire.Visible = false;
phTools.Visible = false;
DataTable dtCategory = new DataTable("table1");
DataTable dtSubCat = new DataTable("table2");
dtCategory = categories.getCompanyCategories().Tables[0];
dtSubCat = categories.getCompanySubCategories().Tables[0];
DataSet dsWhole = new DataSet("Companies");
dsWhole.Tables.Add(dtCategory.Copy());
dsWhole.Tables[0].TableName = "CompanyCategory";
dsWhole.Tables.Add(dtSubCat.Copy());
dsWhole.Tables[1].TableName = "CompanySubCategory";
DataColumn dtParent = dsWhole.Tables["CompanyCategory"].Columns["CatId"];
DataColumn dtChild = dsWhole.Tables["CompanySubCategory"].Columns["CatId"];
DataRelation drPCRelation = new
DataRelation("CatSubCatRelation",dtParent,dtChild,false);
dsWhole.Relations.Add(drPCRelation);
dlCompCategory.DataSource = dsWhole.Tables["CompanyCategory"];
dlCompCategory.DataBind();
dsWhole.Dispose();
dtParent.Dispose();
dtChild.Dispose();
}
}
********************