Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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 25-Dec-12 19:07pm
Comments
Zafar Sultan at 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...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
Member 9581909 at 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">


<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 at 26-Dec-12 11:22am
   
Kindly check the C# code for the REFRESH button.
Mohd. Mukhtar at 27-Dec-12 5:23am
   
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
 
Remove the "ChildrenAsTriggers="False" " from the above line and check.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  

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

  Print Answers RSS
0 DamithSL 280
1 BillWoodruff 170
2 Zoltán Zörgő 170
3 OriginalGriff 134
4 Sergey Alexandrovich Kryukov 120
0 OriginalGriff 7,760
1 DamithSL 5,874
2 Sergey Alexandrovich Kryukov 5,444
3 Maciej Los 5,076
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web04 | 2.8.141223.1 | Last Updated 27 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100