Hi,
friends i have this code of ajax to populate statedropdownlist on countrydropdownlist selectedindex changed, it is working fine
now i want to populate gridview through this code can anybody help me - var val, xmlHttp, xmlDoc, xmlUrl;
-
-
val = document.all.item("ddlCountry").options[document.all.item("ddlCountry").selectedIndex].value;
-
document.all.item("ddlCountry").options[0] = new Option ("Select", "0");
-
xmlUrl = "StateFill.aspx";
-
-
xmlDoc = "&";
-
xmlDoc= xmlDoc + escape("param") + "=" + escape("getState") + "&";
-
xmlDoc= xmlDoc + escape("SCode") + "=" + escape(val);
-
-
if ( navigator.appName == "Netscape" )
-
xmlHttp = new XMLHttpRequest();
-
else
-
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
-
-
xmlHttp.open ("POST", xmlUrl, false)
-
xmlHttp.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded")
-
xmlHttp.send(xmlDoc)
-
-
var v, i;
-
if (xmlHttp.status != "500")
-
{
-
v = xmlHttp.responseText
-
}
-
else
-
{
-
alert("Error Downloading State Information.");
-
}
-
-
document.all.item("ddlState").disabled = false;
-
for (i = document.all.item("ddlState").options.length; i >= 0; i--)
-
document.all.item("ddlState").options[i] = null;
-
-
document.all.item("ddlState").options[0] = new Option ("All", "0");
-
//alert(document.all.item("ddlState").value);
-
if (v.length > 0)
-
{
-
-
var catArray, j, selindex;
-
catArray = v.split("#~");
-
j = 1;
-
selindex = 0;
-
for(i = 0; i < catArray.length; i = i + 2)
-
{
-
document.all.item("ddlState").options[j] = new Option (catArray[i+1], catArray[i]);
-
j = j + 1;
-
}
-
}
-
}
-
else
-
{
-
document.all.item("ddlState").disabled = true;
-
for (i = document.all.item("ddlState").options.length; i >= 0; i--)
-
document.all.item("ddlState").options[i] = null;
-
}
3 2374
Where's the code for the grid?
Note: don't use document.all. It's non-standard and does not work in most browsers. Use document.getElementById() instead making sure that you've set IDs to your elements.
Hi,
friends i have this code of ajax to populate statedropdownlist on countrydropdownlist selectedindex changed, it is working fine
now i want to populate gridview through this code can anybody help me
i have taken state and country dropdownlist on page which has this javascript code, Onpageload countrydropdownlist is filling and "countrydropdownlist's autopostback=fasle"
and my server side code to fillup statedropdownlist is on pageload of "StateFill.aspx" -
var val, xmlHttp, xmlDoc, xmlUrl;
-
-
val = document.all.item("ddlCountry").options[document.all.item("ddlCountry").selectedIndex].value;
-
document.all.item("ddlCountry").options[0] = new Option ("Select", "0");
-
xmlUrl = "StateFill.aspx";
-
-
xmlDoc = "&";
-
xmlDoc= xmlDoc + escape("param") + "=" + escape("getState") + "&";
-
xmlDoc= xmlDoc + escape("SCode") + "=" + escape(val);
-
-
if ( navigator.appName == "Netscape" )
-
xmlHttp = new XMLHttpRequest();
-
else
-
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
-
-
xmlHttp.open ("POST", xmlUrl, false)
-
xmlHttp.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded")
-
xmlHttp.send(xmlDoc)
-
-
var v, i;
-
if (xmlHttp.status != "500")
-
{
-
v = xmlHttp.responseText
-
}
-
else
-
{
-
alert("Error Downloading State Information.");
-
}
-
-
document.all.item("ddlState").disabled = false;
-
for (i = document.all.item("ddlState").options.length; i >= 0; i--)
-
document.all.item("ddlState").options[i] = null;
-
-
document.all.item("ddlState").options[0] = new Option ("All", "0");
-
//alert(document.all.item("ddlState").value);
-
if (v.length > 0)
-
{
-
-
var catArray, j, selindex;
-
catArray = v.split("#~");
-
j = 1;
-
selindex = 0;
-
for(i = 0; i < catArray.length; i = i + 2)
-
{
-
document.all.item("ddlState").options[j] = new Option (catArray[i+1], catArray[i]);
-
j = j + 1;
-
}
-
}
-
}
-
else
-
{
-
document.all.item("ddlState").disabled = true;
-
for (i = document.all.item("ddlState").options.length; i >= 0; i--)
-
document.all.item("ddlState").options[i] = null;
-
}
- protected void Page_Load(object sender, EventArgs e)
-
{
-
if (Request.Params["param"].ToString() == "getState")
-
{
-
string CntId = Request.Params["SCode"]; //.Item["SCode"];
-
Class1 obj = new Class1();
-
-
// OnLineStore.Comm.PopulateDb locobj = new OnLineStore.Comm.PopulateDb();
-
-
string str;
-
str = string.Empty;
-
System.Data.SqlClient.SqlDataReader LOC_dr;
-
LOC_dr = obj.getdata("select intStateTerritoryId,txtStateTerritory from tblMstStateTerritory where intCountryId=" + CntId.ToString() + " Order By txtStateTerritory");
-
-
//LOC_dr = locobj.GetReader("Select StateId,StateName >From OS_StateMaster Where CountryId=" + CntId + " Order By StateName");
-
-
if (LOC_dr.HasRows)
-
{
-
while (LOC_dr.Read())
-
str = str + LOC_dr[0] + "#~" + LOC_dr[1] + "#~";
-
-
}
-
if (str != "")
-
str = str.Substring(0, str.Length - 2);
-
LOC_dr.Close();
-
LOC_dr = null;
-
Response.Write(str);
-
}
I have merged the threads. Please do not double post.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Kate |
last post by:
Hi,
we are now developing complex business application using Ajax
framework. Could anyone point me to the editable javascript grid
control which supports XML loading. Good javascript API would be...
|
by: Woody Splawn |
last post by:
I have a question about technique with regard to filling drop downs.
I have a Winform that has several different tabs and tables associated with
it. In an effort to keep the load time small I...
|
by: Fabio Mastria |
last post by:
Hi all!
In a my simple project I use callback to fill a dropdownlist with xml data
returned by a web service, based on a value which is input via another
dropdownlist.
NOTE: I can't use...
|
by: bonneylake |
last post by:
Hey Everyone,
Well i don't know if my question should be in javascript/ajax or coldfusion, i figure this is more of a coldfusion question. But if this is in the wrong section let me know an all...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |