472,328 Members | 2,165 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 software developers and data experts.

Need help with order of page events and adding dynamic button controls.

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.

Nov 19 '05 #1
1 1933
You've answered the question your self. You need to move the 'Displaying
Fruit types' logic to the Add Image button handler. In Page load, just
display the fruit type for the first time ( while !Ispostback )

<se********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
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.

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mike | last post by:
Hey guys I am pulling my hair out on this problem!!!!! Any help or ideas or comments on how to make this work I would be grateful! I have been...
7
by: Trvl Orm | last post by:
I am working with 2 frames, Left and Right and the main code is in the left frame, which has been attached. Can someone please help me with this...
1
by: Jonathan Yong | last post by:
I observe a very weird behavior when dynamically create web control and bind events to it. Create a C# ASP.NET application, Put a PlaceHolder...
1
by: Karl Seguin | last post by:
i have a dynamically created user control which contains a non-dynamically created ASP.Net button. When the button is clicked, the event is not...
6
by: Robin Bonin | last post by:
In my user contol I am creating a set of dropdownlists. Each list is created based on input from the other lists. The problem I am having is...
5
by: MS Newsgroups | last post by:
Hi, I have a scenario where I am dynamically adding a control from code when a controls event is fired. The problem I have is that when the newly...
1
by: Thanks | last post by:
I have a routine that is called on Page_Init. It retrieves folder records from a database which I display as Link Buttons in a table cell. I set the...
4
by: usl2222 | last post by:
Hi folks, I appreciate any assistance in the following problem: I have a form with a bunch of dynamic controls on it. All the controls are...
6
by: John Rivers | last post by:
hi, here is how to do it and restore sanity to aspx html rendering: (please only reply with sensible architectural discussion - juan) put this...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
1
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.