Click here to Skip to main content
15,881,866 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to built an asp.net(3.5) website.It contains two webforms:

1.Parent.aspx--->This page contains a scriptmanager,updatepanel(having one dropdownlist connected to a sqlsource,createnew button) and a Refresh button outside updatepanel.

-The dropdownlist displays the customer name from the sql table named Customer.

2.Child.aspx--->THis webform contains a textbox named txtCusName and a submit buttton.


Now,What i want to achieve is the following:


-> When the user is at parent.aspx.It looks for the customer name in the dropdownlist.When the user doesnt see the required customer name in list.He presses the createnew button.This will cause the child.aspx to appear over the parent.aspx.

->the user will create new customer name by using txtCusName and submit button.The new customer name gets save in the database.

I have implemented till here but after that when i close the child.aspx and press refresh button in the updatepanel on parent.aspx.The dropdownlist is not getting updated...

how can i update the dropdownlist????plz help me out????? i want to imlement it asap.
Posted
Comments
Zafar Sultan 26-Dec-12 3:31am    
Have you checked the record is storing in the database? if yes, post the code for Parent.aspx here. We will check what's wrong with refresh...

Please make sure that your refresh button and dropdownlist are in same update panel and you are binding dropdownlist with the customer data in refresh button click event.

If above every thing is right then put a break point into refresh button click event and check dropdownlist is binding with customer data or not.

Hope this will help you.
 
Share this answer
 
Comments
Member 9581909 26-Dec-12 11:21am    
hi Mukhtar....
I am posting the complete code for parent.aspx.
The child.aspx is working absolutely fine.


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Parent.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Main Form</title>

<script type="text/javascript">

function win_open() {

window.open("Child.aspx", "", "width=400,height=200", "fulscreen=no", "resizable=yes");

}
</script>



<style type="text/css">
#form1 {
height: 298px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">

<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="False"
UpdateMode="Conditional">
<contenttemplate>

<asp:Label ID="Label1" runat="server" Text="Customer"
style="z-index: 1; left: 38px; top: 54px; position: absolute">
<asp:DropDownList ID="DropDownList1" runat="server"

style="z-index: 1; left: 104px; top: 51px; position: absolute; height: 32px; width: 160px"
DataSourceID="SqlDataSource1" DataTextField="Customer_Name"
DataValueField="Customer_Name">

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:codeConnectionString %>"
SelectCommand="SELECT DISTINCT [Customer_Name] FROM [Customer]">

<asp:Button ID="BtnRef" runat="server" Text="Refresh"

style="z-index: 1; left: 338px; top: 49px; position: absolute; width: 137px"
onclick="BtnRef_Click" />
<asp:Button ID="Btnnew" runat="server" Text="Create New"

style="z-index: 1; left: 527px; top: 48px; position: absolute; width: 139px"
OnClientClick="win_open()" onclick="Btnnew_Click" />



<Triggers>
<asp:AsyncPostBackTrigger ControlID="BtnRef" EventName="Click" />
</Triggers>

</form>
</body>
</html>



And parent.aspx.cs code is as follows:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Btnnew_Click(object sender, EventArgs e)
{
String csname1 = "PopupScript";
Type cstype = this.GetType();
ClientScriptManager cs = Page.ClientScript;
if (!cs.IsStartupScriptRegistered(cstype, csname1))
{
StringBuilder cstext1 = new StringBuilder();
cstext1.Append(@" <script type=text/javascript> function open_win(){window.open(Child.aspx,"",width=400,height=200,fullscreen=no,resizable=yes);} );
cs.RegisterStartupScript(cstype, csname1, cstext1.ToString());
}
}
protected void BtnRef_Click(object sender, EventArgs e)
{
UpdatePanel1.Update();
}
}
Member 9581909 26-Dec-12 11:22am    
Kindly check the C# code for the REFRESH button.
Mohd. Mukhtar 27-Dec-12 5:23am    
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">

Remove the "ChildrenAsTriggers="False" " from the above line and check.
I made a chaange in the c# code for the refresh button.
i just bound the dropdownlist with the button and it did the trick.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900