R
Rubble
Hello,
Ive searched all over the net trying to find an answer to this...so
anybody with some expertise in this area would be greatly appreciated.
Background:
I have a webform that loads a datagrid. This datagrid has a button in
a column that loads another datagrid(user control) when clicked. This
new grid also has a column with a button that loads another user
control. So, there could be 3 user controls on this form if all the
buttons are pushed.
Problem:
The first two controls load fine...but when the button is pushed on
the second control, it disappears and only the first control loaded
onto the page is left. I know this happens due to the way asp.net
loads controls, etc.
Question:
How do I get this to work, so that I can dynamically load as many
controls as I want on the page, as well as set properties for the
controls?
Code Issues:
Each control loaded on the page has its own properties that are set in
the button event. For example, the second control loaded on the page
has an itemid property that is set when the first control runs the
button event. That button event from the first control basically runs
the following code:
public void showItem(object
sender,System.Web.UI.WebControls.CommandEventArgs e)
{
//create a control for item info
Control ctrl = new Control();
string szID = e.CommandArgument.ToString();
//its an asset
ctrl = (Inventory.Controls.assetinfo) LoadControl
(Request.ApplicationPath + Path.AltDirectorySeparatorChar +
"Controls/assetinfo.ascx");
((Inventory.Controls.assetinfo)ctrl).ItemID = szID;
phItemInfo.Controls.Add(ctrl);
}
That control also has a similar method to load a control to show user
information.
**How can I dynamically load the controls...and set their properties,
so that each control remains on the page? Ive tried using the
viewstate, sessions, etc., but nothing seems to allow me to load all
three of these controls while still being able to set their
properties.
Let me know if I need to provide any more info. Thanks again for any
ideas!
x B. Rubble x
Ive searched all over the net trying to find an answer to this...so
anybody with some expertise in this area would be greatly appreciated.
Background:
I have a webform that loads a datagrid. This datagrid has a button in
a column that loads another datagrid(user control) when clicked. This
new grid also has a column with a button that loads another user
control. So, there could be 3 user controls on this form if all the
buttons are pushed.
Problem:
The first two controls load fine...but when the button is pushed on
the second control, it disappears and only the first control loaded
onto the page is left. I know this happens due to the way asp.net
loads controls, etc.
Question:
How do I get this to work, so that I can dynamically load as many
controls as I want on the page, as well as set properties for the
controls?
Code Issues:
Each control loaded on the page has its own properties that are set in
the button event. For example, the second control loaded on the page
has an itemid property that is set when the first control runs the
button event. That button event from the first control basically runs
the following code:
public void showItem(object
sender,System.Web.UI.WebControls.CommandEventArgs e)
{
//create a control for item info
Control ctrl = new Control();
string szID = e.CommandArgument.ToString();
//its an asset
ctrl = (Inventory.Controls.assetinfo) LoadControl
(Request.ApplicationPath + Path.AltDirectorySeparatorChar +
"Controls/assetinfo.ascx");
((Inventory.Controls.assetinfo)ctrl).ItemID = szID;
phItemInfo.Controls.Add(ctrl);
}
That control also has a similar method to load a control to show user
information.
**How can I dynamically load the controls...and set their properties,
so that each control remains on the page? Ive tried using the
viewstate, sessions, etc., but nothing seems to allow me to load all
three of these controls while still being able to set their
properties.
Let me know if I need to provide any more info. Thanks again for any
ideas!
x B. Rubble x