try to give the AutopostBack="True" for the second dropdown. What it does is, the moment you select some value in the DropDown, the page gets refreshed and you will get the value expected where ever you want.
But even if you do not provide that, still you should be getting it. But try the above and see if that does not harm or effect your process.
raja_durai1
Member
236 Points
156 Posts
get ddl selected value
Feb 27, 2012 10:49 AM|LINK
hi to all
i use two drop down in my page .
the second drop down bind based on the First drop down list selected value...
so i use tha ajax post method....
the first and second ddl are bind clearly .. But i cannot get the second ddl selectedvalue in my coadbehind.
how can i get it...
please very urgent for me ....
any one member please help me
Thanks to advance
*" Please excuse my poor English "*
Honnappa
Participant
1112 Points
534 Posts
Re: get ddl selected value
Feb 27, 2012 10:56 AM|LINK
You may be wraped in other controls...if you placed in another control just use FindControl Attribute.
for ex:
DropDownList ddl2=(DropDownList )panel1.FindControl("Your DDl Control ID");Here we Placing ddl2 in Panel
My Profile
dinesh kumar...
Participant
986 Points
247 Posts
Re: get ddl selected value
Feb 27, 2012 10:57 AM|LINK
Can you please post the code so that it will be easy for us??
Jai Jagannath
raja_durai1
Member
236 Points
156 Posts
Re: get ddl selected value
Feb 27, 2012 11:08 AM|LINK
hi
function GetItemName() {
var pageUrl = '<%=ResolveUrl("/Forms/MaterialRequest.aspx")%>';
var projectStatus = $("#<%=ddlCategory.ClientID%>").val();
debugger;
$.ajax({
type: "POST",
url: pageUrl + '/getItemName',
data: '{ItemId:' + projectStatus + '}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function OnlocationsPopulated(dvList) {
$("#<%=ddlItemName.ClientID%>").empty();
if (dvList.d.length > 0) {
$("#<%=ddlItemName.ClientID%>").removeAttr("disabled");
for (i = 0; dvList.d.length > i; i++) {
$("#<%=ddlItemName.ClientID%>").append("<option value=" + dvList.d[i].Value + ">" + dvList.d[i].Text + " </option>");
}
}
else {
$("#<%=ddlItemName.ClientID%>").empty().append('<option selected="selected" value="0">--Select--<option>');
}
}
});
}
<asp:DropDownList ID="ddlItemName" runat="server" CssClass="bigdropdownList">
</asp:DropDownList>
Coad Behind
[System.Web.Services.WebMethod]
public static ArrayList getItemName(string ItemId)
{
string id = ItemId;
ArrayList dvList = new ArrayList();
dvList = BLL.Sales.clsMaterialRequest.GetItemDetails1(ItemId);
return dvList;
}
BLL.Sales.clsMaterialRequest.IsMatReqItemExistInsert(objMR.MaterialRequestItem_MaterialRequestDetails_id, ddlItemName.SelectedValue);
here the value is select
*" Please excuse my poor English "*
raja_durai1
Member
236 Points
156 Posts
Re: get ddl selected value
Feb 27, 2012 11:12 AM|LINK
hai mr honnappa
i use your idea but the selected value is not come for me.
the second ddl was when i click submit butten refreshed ...
then automatically come in first value "0"
what is the problem
*" Please excuse my poor English "*
Honnappa
Participant
1112 Points
534 Posts
Re: get ddl selected value
Feb 27, 2012 11:48 AM|LINK
You may using UpdatePanel .Just Remove the UpdatePanel and try it
My Profile
raja_durai1
Member
236 Points
156 Posts
Re: get ddl selected value
Feb 27, 2012 12:09 PM|LINK
I do not use update pannel....
*" Please excuse my poor English "*
nadellas
Participant
1218 Points
299 Posts
Re: get ddl selected value
Feb 27, 2012 12:27 PM|LINK
try to give the AutopostBack="True" for the second dropdown. What it does is, the moment you select some value in the DropDown, the page gets refreshed and you will get the value expected where ever you want.
But even if you do not provide that, still you should be getting it. But try the above and see if that does not harm or effect your process.
Thanks
Srini
raja_durai1
Member
236 Points
156 Posts
Re: get ddl selected value
Feb 28, 2012 05:08 AM|LINK
hai mr madellas
i am already try to put AutopostBack="True" in second ddl but its not working,
any other idea for u.
thanks
Raja.S
*" Please excuse my poor English "*
abiruban
All-Star
16002 Points
2731 Posts
Re: get ddl selected value
Feb 28, 2012 10:40 AM|LINK
Hi,
second dropdown change into html control
and try again
Thanks...
***DON'T FORGET TO CLICK “MARK AS ANSWER” ON THE POST IF HELPED YOU.