验证中...
Languages: ASP
Categories: 编程语言基础
Latest update 2018-12-28 08:24
gistfile1.txt
Raw Copy
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Sample5_4._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
请选择其中一项运动:<asp:RadioButtonList ID="RadioButtonList1" runat="server" Width="180px">
</asp:RadioButtonList></div>
</form>
</body>
</html>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace Sample5_4
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
//数据生成
DataSet ds = new DataSet();
ds.Tables.Add("stu");
ds.Tables["stu"].Columns.Add("stuNo", typeof(int));
ds.Tables["stu"].Columns.Add("stuName", typeof(string));
ds.Tables["stu"].Columns.Add("stuScore", typeof(int));
ds.Tables["stu"].Rows.Add(new object[] { 1, "乒乓球", 100 });
ds.Tables["stu"].Rows.Add(new object[] { 2, "篮球", 100 });
ds.Tables["stu"].Rows.Add(new object[] { 3, "排球", 100 });
ds.Tables["stu"].Rows.Add(new object[] { 4, "羽毛球", 100 });
ds.Tables["stu"].Rows.Add(new object[] { 5, "足球", 100 });
//绑定数据到ListBox控件
this.RadioButtonList1.DataSource = ds.Tables["stu"];
this.RadioButtonList1.DataValueField = "stuNo";
this.RadioButtonList1.DataTextField = "stuName";
this.RadioButtonList1.DataBind();
}
}
}
}

Comment list( 0 )

You need to Sign in for post a comment

Help Search

Gitee_sixth 5th_float_left_close