标题:用c#写的程序为什么出现下面的情况?求指点。
取消只看楼主
光光123
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-12-21
结帖率:0
已结贴  问题点数:10 回复次数:0 
用c#写的程序为什么出现下面的情况?求指点。
这是源代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace listbox
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
            {
                Data ds = new Data();
                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[] { 1, "王二", 100 });
                ds.tables["stu"].Rows.Add(new object[] { 1, "李珊", 100 });
                ds.tables["stu"].Rows.Add(new object[] { 1, "赵四", 100 });
                ds.tables["stu"].Rows.Add(new object[] { 1, "周五", 100 });
                ds.tables["stu"].Rows.Add(new object[] { 1, "钱六", 100 });
                this.ListBox1.DataSource = ds.Tables["stu"];
                this.ListBox1.DataValueField = "stuNo";
                this.ListBox1.DataTextField = "stuName";
                this.ListBox1.DataBind();

            }
        }

        protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.Label1.Text = "你选择的学生是:学号"+this.ListBox1.SelectedValue.ToString()+"姓名"+this.ListBox1.SelectedItem.Text.ToString ();
        }
    }
}
搜索更多相关主题的帖子: namespace public 
2013-04-07 15:46



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-403235-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.261746 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved