All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
Asp.Net页面输出到EXCEL_[Asp.Net教程]
php5的simplexml解析错误_php资料_编程技术
C#对文件的操作_[Asp.Net教程]
PHP+MYSQL留言本(二)_[PHP教程]
维护为SQL,Server保驾护航_[SQL,Server教程]
ASP.NET,3.5,Extensions新特性:ASP.NET,Dynamic,Data,体验2_[Asp.Net教程]
应用实例:ASP.Net中利用CSS实现多界面两法_.net资料_编程技术
LINQ体验(5)——LINQ,to,SQL语句之Select、Distinct和Count、Sum_[Asp.Net教程]
网页申请表单用户体验设计简述_[Html教程]_0
初学者来看:了解什么是PHP和PHP的功能_php资料_编程技术
Reading number is top 10 pictures
Men's and women's orgasms
Cesarean section, bloody, silently into it!2
Sora aoi mirror memorial classics3
The little woman's bright wire2
邪恶搞笑内涵图
Female model behind the bitterness, often being overcharged4
Steal to eat bacon bird
非常漂亮的泳装美女
男人帮杂志里的惹火性感美女2
西游四格漫画(五)
Download software ranking
Boxer's Top ten classic battle7
Tram sex maniac 2 (H) rar bag10
美女写真2
Tram sex maniac 2 (H) rar bag16
电车之狼R
XML+Web+Service开发教程
asp.net技术内幕
Unix video tutorial13
Sora aoi, the maid, students' uniforms
Boxer Classic video2
delv published in(发表于) 2014/1/16 9:31:46 Edit(编辑)
在ASP.NET中跨页面实现多选_[Asp.Net教程]

在ASP.NET中跨页面实现多选_[Asp.Net教程]

在ASP.NET中跨页面实现多选_[Asp.Net教程]































本文介绍如何在ASP.NET中实现多页面选择的问题。其具体思路很简单:用隐藏的INPUT记住每次选择的项目,在进行数据绑定时,检查保存的值,再在DataGrid中进行选中显示。下面时完整的代码和例子:




查看例子




SelectMultiPages.aspx




<%@ Page EnableViewState="true" CodeBehind="SelectMultiPages.aspx.cs" Language="c#"
AutoEventWireup="false" Inherits="eMeng.Exam.SelectMultiPages" %>



跨页面实现多选






AllowPaging="True" runat="server">






onclick="AddRemoveValues(this)"
value='<%#DataBinder.Eval(Container.DataItem,"Title")%>'/>


































SelectMultiPages.aspx.cs




using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;




namespace eMeng.Exam
{
///


/// SelectMultiPages 的摘要说明。
///

public class SelectMultiPages : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.HtmlControls.HtmlInputHidden HdnSelectedValues;
protected System.Web.UI.WebControls.DataGrid DataGrid1;




private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!Page.IsPostBack)
BindData();
}
private void DataGrid1_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
BindData();
}




void BindData()
{
OleDbConnection cn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
+ HttpContext.Current.Server.MapPath("aspx.mdb"));
OleDbDataAdapter da = new OleDbDataAdapter("Select Title, CreateDate from Document",cn);
DataSet ds = new DataSet();
da.Fill(ds);
DataGrid1.DataSource= ds;
DataGrid1.DataBind();
}




private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
//重新显示所选择的项目
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
if(HdnSelectedValues.Value.IndexOf(((Literal)e.Item.Cells[1].FindControl("TitleShow")).Text) >= 0 )
{
HtmlInputCheckBox ChkSelected = (HtmlInputCheckBox)(e.Item.Cells[0].FindControl("ChkSelect"));
ChkSelected.Checked = true;
}
}
}
private void Button1_Click(object sender, System.EventArgs e)
{
//为了显示的方便进行替换的
Label1.Text = HdnSelectedValues.Value.Replace(",","

  • ");
    }




    #region Web 窗体设计器生成的代码
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }




    ///


    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    ///

    private void InitializeComponent()
    {
    this.DataGrid1.ItemDataBound +=
    new System.Web.UI.WebControls.DataGridItemEventHandler(this.DataGrid1_ItemDataBound);
    this.DataGrid1.PageIndexChanged +=
    new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.DataGrid1_PageIndexChanged);
    this.Button1.Click += new System.EventHandler(this.Button1_Click);
    this.Load += new System.EventHandler(this.Page_Load);




    }
    #endregion




    }
    }




    来源:Csdn















































  • 添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


    Disclaimer Privacy Policy About us Site Map

    If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
    Copyright ©2011-
    uuhomepage.com, Inc. All rights reserved.