M
Mike Speak
I have a user control that I want to use to render 4 menu items
(retrieved from db) on the top of each of my asp.net pages.
The user control defines a table, with one TR and one TD. Within the
TD I have a placeholder defined:
<asplaceHolder ID="categoriesPlaceHolder" Runat="server" />
In the code behind of the user control, on the Page_Load event I am
retrieving data from db and adding controls to the placeholder as
follows:
public class CategoryHeader : System.Web.UI.UserControl
{
protected PlaceHolder categoriesPlaceHolder;
private void Page_Load(object sender, System.EventArgs e)
{
string categoryName = "";
string categoryId = "";
LinkButton categoryItem;
categoriesPlaceHolder = new PlaceHolder();
// DB STUFF HERE
while (myDataReader.Read())
{
// PICK OUT DATA
categoryName = myDataReader["category"].ToString();
categoryId = myDataReader["id"].ToString();
// CREATE A NEW SERVER SIDE LINKBUTTON CONTROL
categoryItem = new LinkButton();
categoryItem.Text = categoryName;
categoryItem.ID = categoryId;
categoryItem.CommandArgument = categoryId;
categoryItem.CommandName = "CategoryLink_Click";
// ADD THE CONTROL TO THE PLACEHOLDER
categoriesPlaceHolder.Controls.Add(categoryItem);
}
}
}
While the rest of the user control is rendering correctly, the
LinkButtons within the placeholder are not rendering at all, there is
nothing within the user control TD where i want the menu items to
appear.
Any expert advice would be greatly appreciated...
TIA
mike...
(retrieved from db) on the top of each of my asp.net pages.
The user control defines a table, with one TR and one TD. Within the
TD I have a placeholder defined:
<asplaceHolder ID="categoriesPlaceHolder" Runat="server" />
In the code behind of the user control, on the Page_Load event I am
retrieving data from db and adding controls to the placeholder as
follows:
public class CategoryHeader : System.Web.UI.UserControl
{
protected PlaceHolder categoriesPlaceHolder;
private void Page_Load(object sender, System.EventArgs e)
{
string categoryName = "";
string categoryId = "";
LinkButton categoryItem;
categoriesPlaceHolder = new PlaceHolder();
// DB STUFF HERE
while (myDataReader.Read())
{
// PICK OUT DATA
categoryName = myDataReader["category"].ToString();
categoryId = myDataReader["id"].ToString();
// CREATE A NEW SERVER SIDE LINKBUTTON CONTROL
categoryItem = new LinkButton();
categoryItem.Text = categoryName;
categoryItem.ID = categoryId;
categoryItem.CommandArgument = categoryId;
categoryItem.CommandName = "CategoryLink_Click";
// ADD THE CONTROL TO THE PLACEHOLDER
categoriesPlaceHolder.Controls.Add(categoryItem);
}
}
}
While the rest of the user control is rendering correctly, the
LinkButtons within the placeholder are not rendering at all, there is
nothing within the user control TD where i want the menu items to
appear.
Any expert advice would be greatly appreciated...
TIA
mike...