S
seanmayhew
I have a form page that that while editing saves the data to an xml doc
before submitting to db. On each page
unload it saves the xmldoc as the user can add multiple items to the
company like product types etc. So for
instance Im adding a fruit company while adding a fruit company I allow
the user to add types of fruit they
carry and display it dynamically using an <asp:table> with image
buttons for editing and deleteing individual
fruit types. After giving the company a name etc and adding fruit types
I submit the xml doc to the db. What Im
having problems with is the order in which things happen when trying to
add fruit types. Since the event
handler for the add fruit type button happens after page load the table
is not populated on post back but
rather on the second post back (adding another fruit type) which then
only displays the first fruit. If you add a third fruit type the page
posts back and displays the first two but not the third and so on. If I
try to
move the fruits table population to the page unload my event handlers
for editing or deleting a fruit type quit working.
here is a quick example
namespace myspace
{
public class myClass : System.Web.UI.Page
{
#region Page Events
private void Page_Load(object sender, System.EventArgs e)
{
GetCompanyInfo();
ShowFruitTypes();
}
private void Page_Unload(object sender, System.EventArgs e)
{
SaveCompanyInfo();
}
#endregion
#region Methods
public void GetCompanyInfo()
{
//Get Company Info from XML
//If company doesnt exist create a new one
//Happens every page load
}
private void SaveCompanyInfo()
{
//Save Company Info to XML
//Happens on page unload
}
public void ShowFruitTypes()
{
//Add Fruit types from XML into <ASP:TABLE>
//Provide Image Buttons with Event Handlers attached to Command
Arguments
//For editing and deleting fruit types.
}
#endregion
#region Event Handlers
private void imgbtnDeleteFruitType_Command(object sender,
CommandEventArgs e)
{//DELETE FRUIT TYPE CODE HERE}
private void imgbtnEditFruitType_Command(object sender,
CommandEventArgs e)
{//EDIT FRUIT TYPE CODE HERE}
private void imgbtnAddFruitType_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{//ADD FRUIT TYPE CODE HERE}
private void imgbtnSaveFruitType_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{//SAVE FRUIT TYPE HERE}
#endregion
}
}
Any help greatly appreciated.
before submitting to db. On each page
unload it saves the xmldoc as the user can add multiple items to the
company like product types etc. So for
instance Im adding a fruit company while adding a fruit company I allow
the user to add types of fruit they
carry and display it dynamically using an <asp:table> with image
buttons for editing and deleteing individual
fruit types. After giving the company a name etc and adding fruit types
I submit the xml doc to the db. What Im
having problems with is the order in which things happen when trying to
add fruit types. Since the event
handler for the add fruit type button happens after page load the table
is not populated on post back but
rather on the second post back (adding another fruit type) which then
only displays the first fruit. If you add a third fruit type the page
posts back and displays the first two but not the third and so on. If I
try to
move the fruits table population to the page unload my event handlers
for editing or deleting a fruit type quit working.
here is a quick example
namespace myspace
{
public class myClass : System.Web.UI.Page
{
#region Page Events
private void Page_Load(object sender, System.EventArgs e)
{
GetCompanyInfo();
ShowFruitTypes();
}
private void Page_Unload(object sender, System.EventArgs e)
{
SaveCompanyInfo();
}
#endregion
#region Methods
public void GetCompanyInfo()
{
//Get Company Info from XML
//If company doesnt exist create a new one
//Happens every page load
}
private void SaveCompanyInfo()
{
//Save Company Info to XML
//Happens on page unload
}
public void ShowFruitTypes()
{
//Add Fruit types from XML into <ASP:TABLE>
//Provide Image Buttons with Event Handlers attached to Command
Arguments
//For editing and deleting fruit types.
}
#endregion
#region Event Handlers
private void imgbtnDeleteFruitType_Command(object sender,
CommandEventArgs e)
{//DELETE FRUIT TYPE CODE HERE}
private void imgbtnEditFruitType_Command(object sender,
CommandEventArgs e)
{//EDIT FRUIT TYPE CODE HERE}
private void imgbtnAddFruitType_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{//ADD FRUIT TYPE CODE HERE}
private void imgbtnSaveFruitType_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{//SAVE FRUIT TYPE HERE}
#endregion
}
}
Any help greatly appreciated.