RadioButtonList用法

最近做了一个市场调查系统,在这之前从来没有做过这些,也没有了解过,只有最近去研究了,其实做完之后,也没有什么特别之处,不过还是学了点以前没有用到过的东西。今天说一下RadioButtonList,以前没有见过也没有用过。

首先在页面上放个RadioButtonList。

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="index" %>



    调查系统后台管理


   

      
               

   



然后在到后台给RadioButtonList进行绑定数据

添加数据呢大家都会想到找到它的集合然后add进行添加,这个也是一样的,它的add方法中添加的是一个ListItem那么我们就应该先new一个ListItem,然后在对ListItem进行赋值,然后把ListItem添加到RadioButtonList中。

ListItem li1 = new ListItem();

li1.Text ="一个数据";

RadioButtonList1.Items.Add(li1);

RadioButtonList1.DataBind();

这样就在RadioButtonList中添加了,很简单吧,呵呵。。。

获取值的话RadioButtonList1.SelectedValue 属性就可以获取

 

你可能感兴趣的:(Asp.Net)