Web API
[HttpPost] //Get Vendor Master
public HttpResponseMessage GetVendorMaster(dynamic inXml)
{
string typeids = inXml.inXml;
int TypeID = Convert.ToInt32(typeids);
return new HttpResponseMessage()
{
Content = new StringContent(clsCommonLib.DataTableToJSON(MasterDetailsBO.GetVendorMaster(TypeID)), System.Text.Encoding.UTF8, "application/json")
};
}
数据: " [{" ID":14," journey_Name":" One Way"},{" ID":15,& #34; journey_Name":"双向"},{" ID":16,"旅程_名称":"多城市"} ]"
Ajax方法:
function bind()
{
$.ajax({
type: "POST",
url: vUrlWithClass,
contentType: "application/json;",
data: param,
async: false,
dataType: "json",
success: function (data) {
var result = $.parseJSON(data.d)
console.log(data)
$.each(result, function (index, list) {
var rdb = "<tr><td><input id=rb" + this['Text'] + " type='radio' name='rbCategories' value=" + this['Text'] + " /><label for=lbl" + this['Text'] + ">" + this['Text'] + "</label></td></tr>";
table.append(rdb);
//$("#cphDashboard_ddlJourneytype").append($("<option></option>").val(list.ID).html(list.journey_Name));
})
},
error: function (result) {
console.log(result)
alert(result)
}
});
}
}
ASPX代码:
<asp:RadioButtonList ID="rdbJourneyTypeAir" runat="server" RepeatDirection="Horizontal" CssClass="FormatRadioButtonList">
</asp:RadioButtonList>
但是我无法将数据绑定到单选按钮列表
答案 0 :(得分:0)
从示例代码中可以看出: -
this["Text"]
评估的内容是什么?理想情况下,它应该是一个迭代器,为转发器控件启用动态ID。所有单选按钮看起来都是一样的。如果报告了任何特定错误,请更新帖子