Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
My click event:

<div id="btncontinue3">
<table ><tr><td>
<input id="btncon3" type="button" value="Continue" />
</td></tr>
</table>
</div>


while click on button Button , calling ajax call. i got the all hidden values on page load. So everything passing correctly.

my ajax call webmethod
[WebMethod(EnableSession = true)]

public static string Getmethod(string Country, string Zipcode, string tableName)
{
DataTable dt = new DataTable();
dt = getdtmethod();// here i am getting all values :
dt.TableName=tableName;
string result;
using (StringWriter sw = new StringWriter())
{
dt.WriteXml(sw);
result = sw.ToString();
}

return result;
}

i checked xml string. i got like follow

<DocumentElement>
<Ratesval>
<code>11A</code>
<description>Foot Ball</description>
<Hint>10:30 A.M.</Hint>
<via_code>S0</via_code>
</Ratesval>
<Ratesval>
<code>21A</code>
<description>Volley Ball</description>
<Hint>01:30 A.M.</Hint>
<via_code>P0</via_code>
</Ratesval>

</DocumentElement>

I did not get any error: So, ajax success method calls. even i found table name and code, description (using alert and debuger -checked). But
it is not binding into radiobuttonlist i guess. becuase radio button is not showing on screen. Just blank.

$("#btncontinue3").click(function () {
debugger;
// calculate shipping rate using using ajax call
var country = $("#<%=txtshipcountry.ClientID%>").val();

var zipcode = $('#<%=hdnvalforzipshipping.ClientID%>').val();

var tableName = 'Ratesval';
var rdbtnlist = $("#<%=rdbtnlistshipping.ClientID%>");

$.ajax({

type: "POST",
contentType: "application/json;charset=utf-8",
url:"../kout.aspx/Getmethod",
data: "{'Country':'" + country + "','Zipcode':'" + zipcode + "','tableName':'"+tableName+"'}",
dataType: "json",
success: function (response) {

$(response.d).find('Ratesval').each(function () {
// Get the OptionValue and OptionText Column values.
var OptionValue = $(this).find('code').text();
var OptionText = $(this).find('description').text();
alert(OptionValue);
alert(OptionText);
// Create an Option for radiobuttonlist.
var option = $("<option>" + OptionText + "</option>");
option.attr("value", OptionValue);

rdbtnlist.append(option);
});
},
error: function (result) {
alert("Error in code");
}
});



});


// radiobuttonlist declared and accessed in jquery using clientID as it is child page(content placeholder).

<asp:RadioButtonList ID="rdbtnlistshipping" runat="server">

</asp:RadioButtonList>
Posted
Comments
[no name] 13-Oct-15 1:04am    
Are you getting alert message with proper value after getting data from server?
Amit Jadli 13-Oct-15 1:35am    
http://www.codedigest.com/Articles/jQuery/259_Populating_RadioButtonList_Using_jQuery_JSON_in_ASPNet.aspx

This link will help you...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900