C
Craig Kenisston
Hi,
I'm writing a little asp site, with just a single main default.aspx page and
a couple of web user's control.
I have the page in a way, that I have a left hand menu, and alternatively,
according to the selection, any of the .ascx components is loaded into a
tables's cell with the proper content.
This works great except for one thing : The menu on the left is a large list
of items retrieved from a database, in a datalist with an hypelink . Each
time any of these items is clicked, the query to retrieve this list is hit
again.
I have something like this :
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (Page.IsPostBack == false)
{
DataList1.DataSource = get data reader; // SQL activity here
DataList1.DataBind();
if (Request.Params["goto"] != null)
{
string sGoto;
sGoto = Request.Params["goto"];
CenterPane.Controls.Add(Page.LoadControl("~/ResourcesList.ascx"));
CenterPane.Visible = true;
}
}
I thought that with the IsPostBack = false, I would avoid this code being
called in each click. I think that was wrong.
I'm looking advise on how to codify this in order to load the left hand menu
only once per user's session.
Thanks in advance,
I'm writing a little asp site, with just a single main default.aspx page and
a couple of web user's control.
I have the page in a way, that I have a left hand menu, and alternatively,
according to the selection, any of the .ascx components is loaded into a
tables's cell with the proper content.
This works great except for one thing : The menu on the left is a large list
of items retrieved from a database, in a datalist with an hypelink . Each
time any of these items is clicked, the query to retrieve this list is hit
again.
I have something like this :
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (Page.IsPostBack == false)
{
DataList1.DataSource = get data reader; // SQL activity here
DataList1.DataBind();
if (Request.Params["goto"] != null)
{
string sGoto;
sGoto = Request.Params["goto"];
CenterPane.Controls.Add(Page.LoadControl("~/ResourcesList.ascx"));
CenterPane.Visible = true;
}
}
I thought that with the IsPostBack = false, I would avoid this code being
called in each click. I think that was wrong.
I'm looking advise on how to codify this in order to load the left hand menu
only once per user's session.
Thanks in advance,