asp.net 4.5 练习~test5-1
发布日期:2021-05-06 21:15:33 浏览次数:22 分类:技术文章

本文共 1304 字,大约阅读时间需要 4 分钟。

webform1.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="test5_1.WebForm1" %>
候选国家:    你喜欢的国家:
中国
美国
挪威
荷兰
瑞士
德国
英国

webform1.aspx.cs

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace test5_1{    public partial class WebForm1 : System.Web.UI.Page    {        protected void Page_Load(object sender, EventArgs e)        {        }        protected void btn_select_Click(object sender, EventArgs e)        {            int count = lbxSource.Items.Count;            int index = 0;            for (int i = 0; i < count; i++)            {                ListItem item = lbxSource.Items[index];                if (lbxSource.Items[index].Selected == true)                {                    lbxDestnition.Items.Add(item);                }                index++;            }            //这段代码有缺陷,框1选中的国家,加入框2时,没有做重复项判断,所以会重复添加内容。        }    }}

 

上一篇:asp.net 4.5 练习~test5-2
下一篇:asp.net 4.5 练习 ~test4-11

发表评论

最新留言

关注你微信了!
[***.104.42.241]2025年03月30日 15时04分24秒