Senior & Expert .Net Developers Discussion Forum by Nyros Technologies

HIRE .Net Expert Developers Programmers Coders From India
Ruby on Rails PHP .Net Developers Community, Nyros Technologies, Kakinada
 
Log in  or IF not a member please REGISTER
Username:
Password:   


Keyword
Log in | Profile 

How to populate items to dropdown in ASP.NET using AJAX

 
Post new topic   Reply to topic    Senior & Expert .Net Developers Discussion Forum by Nyros Technologies Index -> Ajax.Net
View previous topic :: View next topic  
Author Message
Jubeda



Joined: 30 Aug 2007
Posts: 6

PostPosted: Thu Aug 30, 2007 10:32 am    Post subject: How to populate items to dropdown in ASP.NET using AJAX Reply with quote

Hi,

How to populate the items to the dropdown and when changing the
item in the first dropdown box the corresponding items must be display
in the second dropdown.can anybody send a sample script.
Back to top
View user's profile Send private message
Abhi



Joined: 21 Aug 2007
Posts: 145

PostPosted: Thu Aug 30, 2007 10:53 am    Post subject: Reply with quote

Hi jubeda,

I think the following code will be helpful to u.I took one database file
cities.mdb. In one dropdown i populated the states of us.In another dropdown i populated the corresponding state cities.


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Ajax_DDL_Cities.aspx.cs" Inherits="Default2" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>

<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:UpdateProgress id="UpdateProgress1" runat="server" AssociatedUpdatePanelID ="UpdatePanel1">
<progresstemplate>
</progresstemplate>
</asp:UpdateProgress>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</div>
<asp:UpdatePanel id="UpdatePanel1" runat="server">
<contenttemplate>
&nbsp; &nbsp;
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="AccessDataSource1" AutoPostBack="true"
DataTextField="State" DataValueField="State" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="AccessDataSource2"
DataTextField="City" DataValueField="City">
</asp:DropDownList>
<asp:AccessDataSource ID="AccessDataSource2" runat="server" DataFile="~/App_Data/cities.mdb"
SelectCommand="SELECT Distinct [City] FROM [Commercial] Where state=@stateid">
<SelectParameters >
<asp:ControlParameter Name =stateid ControlID ="DropDownList1"/>
</SelectParameters>
</asp:AccessDataSource>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/cities.mdb"
SelectCommand="SELECT DISTINCT [State] FROM [Commercial]">
</asp:AccessDataSource>
</contenttemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Senior & Expert .Net Developers Discussion Forum by Nyros Technologies Index -> Ajax.Net
Page 1 of 1


 latest topics 
 Topics   Replies   Author   Views   Last Post 
No new posts Is there any control like Gridview in WPF?
1 mukundh 11 Fri Jul 30, 2010 11:16 am
setty View latest post
No new posts Getting data from the other pages by sending a request.
1 pavani 8 Fri Jul 30, 2010 10:16 am
rajesh View latest post
No new posts Viewing or Reading an Assembly
0 sek 20 Mon Jul 26, 2010 10:33 am
sek View latest post
No new posts Multiple technologies to develop iPhone applications:
0 Ramya sree 21 Mon Jul 26, 2010 10:09 am
Ramya sree View latest post
No new posts What is the Difference Between CLR, CLS and CTS ?
1 pavani 27 Mon Jul 26, 2010 5:35 am
pavani View latest post
No new posts What is Android and How to install Android SDK.??
0 pavani 17 Mon Jul 26, 2010 4:46 am
pavani View latest post
No new posts Open-source libraries for iPhone application development:-
0 Teena 19 Sun Jul 25, 2010 8:17 am
Teena View latest post
No new posts Famous Mobile Sites:
1 kumar 17 Sun Jul 25, 2010 7:33 am
Teena View latest post
No new posts Introduction to PhoneGap framework
0 Dileep 24 Sun Jul 25, 2010 7:00 am
Dileep View latest post
No new posts Objective-C on Windows:
0 suraj 22 Sun Jul 25, 2010 6:16 am
suraj View latest post




Hire an expert .Net developer / coder / programmer or development team from India now!!

Other Forums : Ruby on Rails   ::   PHP   |   Free unlimited HTML CSS templates download

Nyros Technologies   |   Kakinada City Portal   |   Developers Blog   |   About .Net Experts   |   More