1. 程式人生 > >RadioButtonList繫結後臺的資料。

RadioButtonList繫結後臺的資料。

在前臺,放置一個

   <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;