首页 > 技术文章 > RadioButtonList绑定后台的数据。

ZkbFighting 2019-01-14 14:25 原文

在前台,放置一个

   <td style="width: 650px;"><asp:RadioButtonList ID="RadioButtonList2" runat="server" RepeatDirection="Horizontal"></asp:RadioButtonList></td>

在后台绑定上展示的内容。

DataTable dtInvoiceType = OrderData.GetInvoiceType();
RadioButtonList2.DataSource = dtInvoiceType;
RadioButtonList2.DataTextField = "Invoice_Name";
RadioButtonList2.DataValueField = "Invoice_ID";
RadioButtonList2.DataBind();

下面的FindByValue的方法是在加载的时候,页面上直接显示出来对应的值。

RadioButtonList2.Items.FindByValue(dtInfo.Rows[0]["Invoice_title"].ToString()).Selected = true;

推荐阅读