Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Select drop down list value based on selection in pop up page

Posted on 2009-05-20
3
Medium Priority
?
558 Views
Last Modified: 2012-05-07
I have a page that contains a drop down list of values.
Next to the drop down, I have an clickable image icon that pops up a new window that allows the user to search and select for a value.

When the user clicks on that value in the pop up window, the id is then returned to the parent page.
How can I set the selected value of the drop down with the value that was selected on the popup page?
page1.aspx
'Need to set the selected value of this drop down
'based on what the user selects in the pop up window
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
 
<input type="text" name="CustomerID" value  "" />                                                        
                                                        <img alt="" src="icon_preview.gif" onclick='targetitem = document.forms[0].CustomerID;dataitem = window.open("CustomerLookup.aspx", "dataitem", "toolbar=no,menubar=no,width=550,height=500"); dataitem.targetitem = targetitem' />
 
Popup page
 
    <script type="text/javascript"> 
    function select_item(item)     {
        targetitem.value = item;
        top.close();
        return false;
    }
    </script>
 
This is actually in a grid
                        <itemtemplate>
                            <a href="" onclick='return select_item("<%#Eval("CustomerID")%>")'> <%#Eval("FirstName")%> <%#Eval("LastName")%></a>
                        </itemtemplate>

Open in new window

0
Comment
Question by:JRockFL
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 16

Expert Comment

by:Steve Krile
ID: 24435499
Sorry for the misdirection here, but is this an Ajax enabled application.  If so, sounds like what you really could use is a Modal Popup and Update panel.  If you respond back saying, "Yeah, I could use Ajax", I'll hook you up with a pretty simple way of getting what you want here.
0
 
LVL 8

Author Comment

by:JRockFL
ID: 24435523
Yeah I could use Ajax
:)
0
 
LVL 16

Accepted Solution

by:
Steve Krile earned 2000 total points
ID: 24435671
Sweet.  So, here is how I'd do what you are trying to accomplish - please not that a lot of the code below would need to be cleaned up for it to "work", things like data connections and page configurations to properly reference the Ajax toolkit.

.aspx Page:

          <asp:UpdatePanel runat="server" ID="MainContent" UpdateMode="Conditional">
              <Triggers>
                  <asp:AsyncPostBackTrigger ControlID="MyGrid" EventName="SelectedIndexChanged"
              </Triggers>
              <ContentTemplate>
                  <asp:Label runat="server" ID="SelectedID" />
                <asp:DropDownList runat="server" ID="MyList" >
                      <asp:ListItem Text="val1" Value="0" />
                      <asp:ListItem Text="val2" Value="1" />
                  </asp:DropDownList>
                  <asp:ImageButton runat="server" ID="ModalShow" ImageUrl="~/images/myimagebutton.gif" />
                  <asp:Panel runat="server" ID="MyModal" Style="display:none;">
                      <asp:SqlDataSource ID="MyGridData" Runat="server" />
                      <asp:GridView ID="MyGrid" runat="server"  
                          DataKeyNames="MyDataIDValueName"
                          DataSourceID="MyGridData"
                          OnSelectedIndexChanged="MyGrid_Selected" />
                      <asp:Button runat="server" ID="CloseModal" Text="Cancel" />
                  </asp:Panel>
                  <cc1:ModalPopupExtender runat="server" ID="MyModalExtender"
                      PopupControlID="MyModal" TargetControlID="ModalShow"
                      CancelControlID="CloseModal" />
              </ContentTemplate>
          </asp:UpdatePanel>



.aspx.vb page:


    Protected Sub MyGrid_Selected(ByVal sender As Object, ByVal e As EventArgs) Handles MyGrid.SelectedIndexChanged
        Dim MyID As Integer = CType(MyGrid.SelectedDataKey.Value, Integer)
        SelectedID.Text = MyID.ToString()
        MyModalExtender.Hide()
    End Sub
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question