R
Rafi
Hi,
In my database I have table category where I store diffrent categories and
subcategories. I decied to create LinkButtons dinamically with assigned name
of category and its id. I also implemented an event onClick which task is to
create LinkButton subcategories.
When the page is loaded main categories are displayed, when I click on any
of that buttons a subcategories will appear on the screen.
The problem is, when I click on subcategory LinkButton.
All subcategories disappear and only LinkButtons with main categories remain
on the page.
What is wrong?
private void Page_Load(object sender, System.EventArgs e)
{
SqlDataReader dr;
KategorieGlowneProc.Connection.Open(); // stored procedure to get main
categories
dr = KategorieGlowneProc.ExecuteReader();
while ( dr.Read() )
{
LinkButton button = new LinkButton();
button.Attributes.Add("runat","server");
button.ID = dr.GetValue(0).ToString();
button.Text = dr.GetValue(2).ToString();
button.Click += new System.EventHandler(podkategoria);
Page.Controls[1].Controls.Add(button);
Page.Controls[1].Controls.Add(new LiteralControl("<br>"));
}
dr.Close();
KategorieGlowneProc.Connection.Close();
}
private void podkategoria(object sender, System.EventArgs e)
{
LinkButton przycisk = (LinkButton)sender;
SqlDataReader dr;
PodkategorieProc.Parameters["@id_kategorii"].Value = przycisk.ID; //
stored procedure to retrive subcategories
PodkategorieProc.Connection.Open();
dr = PodkategorieProc.ExecuteReader();
while( dr.Read() )
{
LinkButton button = new LinkButton();
button.Attributes.Add("runat","server");
button.ID = dr.GetValue(0).ToString();
button.Text = dr.GetValue(2).ToString();
button.Click += new System.EventHandler(podkategoria);
Page.Controls[1].Controls.Add(new LiteralControl("<br>"));
Page.Controls[1].Controls.Add(button);
}
dr.Close();
PodkategorieProc.Connection.Close();
}
Thanks for help
Rafi
In my database I have table category where I store diffrent categories and
subcategories. I decied to create LinkButtons dinamically with assigned name
of category and its id. I also implemented an event onClick which task is to
create LinkButton subcategories.
When the page is loaded main categories are displayed, when I click on any
of that buttons a subcategories will appear on the screen.
The problem is, when I click on subcategory LinkButton.
All subcategories disappear and only LinkButtons with main categories remain
on the page.
What is wrong?
private void Page_Load(object sender, System.EventArgs e)
{
SqlDataReader dr;
KategorieGlowneProc.Connection.Open(); // stored procedure to get main
categories
dr = KategorieGlowneProc.ExecuteReader();
while ( dr.Read() )
{
LinkButton button = new LinkButton();
button.Attributes.Add("runat","server");
button.ID = dr.GetValue(0).ToString();
button.Text = dr.GetValue(2).ToString();
button.Click += new System.EventHandler(podkategoria);
Page.Controls[1].Controls.Add(button);
Page.Controls[1].Controls.Add(new LiteralControl("<br>"));
}
dr.Close();
KategorieGlowneProc.Connection.Close();
}
private void podkategoria(object sender, System.EventArgs e)
{
LinkButton przycisk = (LinkButton)sender;
SqlDataReader dr;
PodkategorieProc.Parameters["@id_kategorii"].Value = przycisk.ID; //
stored procedure to retrive subcategories
PodkategorieProc.Connection.Open();
dr = PodkategorieProc.ExecuteReader();
while( dr.Read() )
{
LinkButton button = new LinkButton();
button.Attributes.Add("runat","server");
button.ID = dr.GetValue(0).ToString();
button.Text = dr.GetValue(2).ToString();
button.Click += new System.EventHandler(podkategoria);
Page.Controls[1].Controls.Add(new LiteralControl("<br>"));
Page.Controls[1].Controls.Add(button);
}
dr.Close();
PodkategorieProc.Connection.Close();
}
Thanks for help
Rafi