IT Community - Software Programming, Web Development and Technical Support

Is there any way to load data in dropdownlist based on the other without Page Refresh

This is a discussion on Is there any way to load data in dropdownlist based on the other without Page Refresh within the ASP and ASP.NET Programming forums, part of the Web Development category; Hi, How to load data in dropdownlist based on other without refreshing the page and without using Ajax?.......


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > ASP and ASP.NET Programming

Register FAQ Members List Calendar Mark Forums Read
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 02-02-2008, 05:02 AM
poornima poornima is offline
D-Web Sr.Programmer
 
Join Date: Dec 2007
Posts: 189
poornima is on a distinguished road
Smile Is there any way to load data in dropdownlist based on the other without Page Refresh

Hi,
How to load data in dropdownlist based on other without refreshing the page and without using Ajax?....
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-14-2008, 05:40 AM
Kirubhananth Kirubhananth is offline
D-Web Programmer
 
Join Date: Feb 2008
Location: My native is Madurai but now in Chennai
Posts: 61
Kirubhananth is on a distinguished road
Send a message via AIM to Kirubhananth Send a message via Skype™ to Kirubhananth
Unhappy Re: Is there any way to load data in dropdownlist based on the other without Page Ref

I too have that doubt.
While selecting an item from a dropdownlist box,the page was refreshed and i had to loss the selected data and the first element was automatically selected.
If you get the answer for this then please reply me.
-Kirubha
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-15-2008, 02:38 AM
poornima poornima is offline
D-Web Sr.Programmer
 
Join Date: Dec 2007
Posts: 189
poornima is on a distinguished road
Smile Re: Is there any way to load data in dropdownlist based on the other without Page Ref

Hi,
We can avoid full page refreshment while loading data in dropDownlist using XML.For this u need the XML File to be generated for ur table.
Here i used countryContent.xml which contains both country and its related state.
protected void Page_Load(object sender, EventArgs e)
{
DataTable dataTable = new DataTable();
DataRow dr;
dataTable.Columns.Add("countryName",typeof(string) );
if (!IsPostBack)
{
XmlDocument xdoc = new XmlDocument();
XmlTextReader xtr = new XmlTextReader(Server.MapPath("countryContent.xml") );
xdoc.Load(xtr);
XmlNodeList xnl = xdoc.DocumentElement.SelectNodes("country");
foreach (XmlNode xnode in xnl)
{
dr = dataTable.NewRow();
dr[0] = xnode.Attributes[0].Value;
dataTable.Rows.Add(dr);
}
countryDropDownList.DataSource = dataTable;
countryDropDownList.DataValueField = "countryName";
countryDropDownList.DataBind();
}
}

protected void countryDropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
stateDropDownList.Items.Clear();
GetStateFromCountry();

}
public void GetStateFromCountry()
{
int flag = 0;
DataTable dataTable = new DataTable();
DataRow dr;
dataTable.Columns.Add("stateName", typeof(string));
XmlDocument xdoc = new XmlDocument();
XmlNode snode=null;
XmlTextReader xtr = new XmlTextReader(Server.MapPath("countryContent.xml") );
xdoc.Load(xtr);
XmlNodeList xnl = xdoc.DocumentElement.SelectNodes("country");
foreach (XmlNode xnode in xnl)
{
if (xnode.Attributes[0].Value == countryDropDownList.SelectedItem.Text)
{
flag = 1;
snode = xnode;

}
}
if (flag == 1)
{
XmlNodeList stateNodeList = snode.ChildNodes;
foreach (XmlNode xsnode in stateNodeList)
{
dr = dataTable.NewRow();
dr[0] = xsnode.Attributes[1].Value;
dataTable.Rows.Add(dr);
}
}

stateDropDownList.DataSource = dataTable;
stateDropDownList.DataTextField = "stateName";
stateDropDownList.DataBind();
}

try this..only partial refresh is there..That is u cant get whole page refreshed instead u will have min refreshment.I hope this helps to avoid full page refreshment.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/asp-asp-net-programming/5161-there-any-way-load-data-dropdownlist-based-other-without-page-refresh.html
Posted By For Type Date
Is there any way to load data in dropdownlist based on the other without Page... - Ajax This thread Refback 02-24-2008 01:07 AM

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to bind values of onedropdownlist to another dropdownlist in another page? poornima ASP and ASP.NET Programming 0 02-03-2008 09:07 PM
What methods are fired during the page load? prasath ASP and ASP.NET Programming 1 07-18-2007 03:04 AM
How can I automatically load another page or reload the same page? Archer C# Programming 0 07-16-2007 12:10 AM
Refresh a page through Javascript Sathish Kumar HTML, CSS and Javascript Coding Techniques 0 07-02-2007 07:35 AM
Refresh Page for a Certain Time of Interval Anandavinayagam ASP and ASP.NET Programming 2 03-19-2007 04:59 AM


All times are GMT -7. The time now is 07:37 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0