473,396 Members | 1,849 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Simple problem: Rebinding DropDownList After More Data Entered on Separate aspx Web Form

I have this simple scenario.

--------
Choose an item ->dropdownlist-> or <a>Create a new item</a>

--------

When someone decides to click on the create a new item link, it takes
them to a page in which they can enter more records to the database
field to which the dropdownlist is bound.

Then they close this page. And they are again looking at the
dropdownlist. However, I want their newly created data to be present
in the dropdownlist after they close the enter-more-data page.

HOW!!!?!

I'm simply trying to react to a client envet of them closing this
window created by an <asp:HyperLink> link, and then having that event
trigger another DataBind of the dropdownlist on the original page.
Coordinating a client event with a code-behind method is proving
difficult.

Please help.
Thanks,
Keith
Nov 18 '05 #1
4 2502
You can use JS on the AddNewItems.aspx page which opens in a new window to control the page which opened it (The parent page which contains the Bound DropDownList). So when you click on the <asp:HyperLink /> on AddNewItems.aspx page, JS code is fired that re-direct the parent window to itself, and this would cause the data to be re-bound

[AddNewItems.aspx
<asp:HyperLink
id="HyperLink1"
runat="server"
NavigateUrl="javascript:window.opener.location = 'BoundDropDownListPage.aspx';"
Close Add Items Windo
</asp:HyperLink

Also rather than

javascript:window.opener.location = 'BoundDropDownListPage.aspx'

You can also try, but this may cause problems if you have already PostedBack the parent page

javascript:window.opener.location.reload()

Rasika Wijayaratne
Nov 18 '05 #2
<asp:HyperLink
id="HyperLink1"
runat="server"
NavigateUrl="javascript:window.opener.location = 'BoundDropDownListPage.aspx';"
Close Add Items Windo
</asp:HyperLink

You can add window.close(); to the above to close the opened window as well

<asp:HyperLink
id="HyperLink1"
runat="server"
NavigateUrl="javascript:window.opener.location = 'BoundDropDownListPage.aspx';window.close();"
Close Add Items Windo
</asp:HyperLink

Rasika Wijayaratne
Nov 18 '05 #3
Thanks for your reply.

Let me try to clear this up somewhat for the both of us.

- First, if I could do this all without client-script, I'd
be happy to (do it all in the code-behind of the two linked .aspx pages).

- Second, what exactly does window.opener.location do?
- Is opener a reference back to the parent window?
- And location? - the new url to be set for the parent window?

- Third, It seems that If I put that
<asp:HyperLink ...>Close Window</asp:HyperLink>
in the crtItems.aspx page, then the user would have to click on
the link to close the window - what if they click the 'x'? Is there
someway I could trigger an 'onClose' (or onUnload) event for the
crtItems.aspx window and call the same javascript code to cover
universal closings of the window?

- Fourth, there are other DropDownLists on the BoundDropDownList.aspx
page, and I'm afraid if reloading it will lose choices of those DDLs
reload those and set the page back into its initial state (in which
some controls are not enabled).

- Fifth, here's a look at some code from the two pages:

[BoundDropDownListPage.aspx]
==============================================
<div id="thisDiv">
<span id="step1">1. Choose an Item from the DropDownList</span>
<asp:dropdownlist id="ddlItems" runat="server" AutoPostBack="True" />
<asp:hyperlink id="hlCrtItems" runat="server" NavigateUrl="crtItems.aspx"
Target="_blank">or Create New Item</asp:hyperlink>
</div>

[BoundDropDownListPage.aspx.vb]
==============================================
Sub BindItemsDDL()
... ' Code to open the connection, pull from DB, and bind to DDL
... ' Called when a previous page event (or DDL change) occurs
End Sub

[crtItems.aspx]
==============================================
<div>
<span>1. Enter Item One</span>
<asp:textbox id="txtItem1" runat="server"/>
<asp:requiredfieldvalidator id="rfvtxtItem1" runat="server"
Text="Required Field!" ControlToValidate="txtItem1"/>
</div>
<asp:Button ID="btnSubmitNewItem" runat="server" Text="Submit New Item" />

[crtItems.aspx.vb]
==============================================
Private Sub btnSubmitNewLab_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnSubmitNewLab.Click
... ' An insert SQL stmt, new command, open conn, execute cmd, close conn
End Sub
Nov 18 '05 #4
Unfortunately, there's no way for the server to initiate the contact with
the client so once page1 has been rendered, anything that happens in page2,
such as a hyperlink click, can't be passed by the server back to page1.

One way in which I have accomplished similar tasks in the past is to use Web
Dialogs. When the user clicks the appropriate "add" button in the web
dialog:
Pass the information to the parent page,
Set hidden form field values in javascript,
Submit the form programmatically,
DataBind the drop-down list again at that time.

In the case of error or failure to add, you can set a client side variable
that is checked on page load and re-open the web dialog again if necessary
when the page loads.

In a fast intranet situation it works very well. On dial-up, auto postback
of any kind sucks!

Dale

"Keith" <Th**********@comcast.net> wrote in message
news:6c**************************@posting.google.c om...
I have this simple scenario.

--------
Choose an item ->dropdownlist-> or <a>Create a new item</a>

--------

When someone decides to click on the create a new item link, it takes
them to a page in which they can enter more records to the database
field to which the dropdownlist is bound.

Then they close this page. And they are again looking at the
dropdownlist. However, I want their newly created data to be present
in the dropdownlist after they close the enter-more-data page.

HOW!!!?!

I'm simply trying to react to a client envet of them closing this
window created by an <asp:HyperLink> link, and then having that event
trigger another DataBind of the dropdownlist on the original page.
Coordinating a client event with a code-behind method is proving
difficult.

Please help.
Thanks,
Keith

Nov 18 '05 #5

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

Similar topics

1
by: Thomas Kern | last post by:
Hi everybody! I have a dropdownlist on a aspx page. The dropdownlist is filled in the page_load event like this: If Not Page.IsPostBack Then BindData() End If The Bind Data method goes to...
10
by: Sacha Korell | last post by:
I'm trying to load a drop-down list with all DropDownList control names from another page. How would I be able to find those DropDownList controls? The FindControl method will only find a...
5
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
string connectionString1 = "server=(local); user=sa;password=sa; database=sonic"; System.Data.SqlClient.SqlConnection dbConnection1 = new System.Data.SqlClient.SqlConnection(connectionString1);...
1
by: Liz | last post by:
I have a page with several dropdownlists, several text boxes and several buttons which perform calculations. I need to validate one dropdownlist (not the whole page) with the click of one button. I...
10
by: Assimalyst | last post by:
Hi, I'm attempting to use a data reader to load data from a single table, tblCountry, with two columns, countryNo (the Key) and countryName, into a DropDownList box. Here's the code: ...
10
by: ads | last post by:
hi, after binding the dropdownlist to a datasource, ive experience this error "Cannot have multiple items selected in a dropdownlist" after using the code:...
10
by: B. Chernick | last post by:
I am using a System.Web.UI.WebControls.Table control on a screen. (Dot Net 1.1) My problem is this: The table is programmatically reconstructed on every postback. Each table row contains two...
1
by: Ted | last post by:
In MS SQL I used the following to create a stored procedure. USE AdventureWorks; GO IF OBJECT_ID ( 'HumanResources.usp_My_Search', 'P' ) IS NOT NULL DROP PROCEDURE HumanResources.usp_My_Search;...
0
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.