I have a Serverside code in Java and client pages in .Net. Now I have to load a dropdown list in .Net from a serverside action class in Java. To do this, I created a asp dropdownlist as shown:
<asp:DropDownList ID="invoiceYear" runat="server" OnLoad='<%#GetYearRange()%>'
Width="150px" AutoPostBack="True">
</asp:DropDownList>
and I have a method GetYearRange in aspx.cs as shown:
[WebMethod]
public static string GetYearRange()
{
System.Diagnostics.Debug.WriteLine("I am in");
string strNewValue = "page=" + "" + "&rows=" + "" + "&sort=" + "" + "&order=" + "";
string ss = ServerUtil.getServerString(strNewValue, "/invoice/invoice!getYearRange.action");
System.Diagnostics.Debug.WriteLine("ss-->" + ss);
return ss;
}
it is not going to that method. Please advice me how would I get the results from this method into my dropdownlist??
It should not be decorated with the
[WebMethod]attribute, and you also are not calling the method correctly. If you want to have this bind itself with values you need to set its DataSource to a proper collection. If you are trying to set its current selected value you will need to set that specifically. The real question I would have is: What are you trying to do with this code?If you are attempting to load the dropdownlist with values received from your service call:
If you already have it DataBound but you need to force the selected item to be the result of your service, you need to use the
OnDataBoundevent: