您的位置:首页精文荟萃软件资讯 → 制作一个简单的服务器端控制

制作一个简单的服务器端控制

时间:2004/10/7 19:18:00来源:本站整理作者:蓝点我要评论(0)

2000082805.aspx

-------------------------------------------------------------

<%@ register="" tagprefix="CJ" namespace="cjServerControls">



  

  

  



    



<CJ:xmlDocReader  listText="au_id" listValue="au_id" runat="server"

path="C:\Inetpub\wwwroot\myASP\tutorials\authors.xml" />

    





  







2000082805a.cs

-------------------------------------------------------------

using System;

using System.Data;

using System.IO;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;



namespace cjServerControls

{

public class xmlDocReader : Control, INamingContainer

{

string _xmlPath;

string _listID;

string _listValue;



public string Path

{

get { return _xmlPath; }

set { _xmlPath = value; }

}



public string listText

{

get { return _listID; }

set { _listID = value; }

}



public string listValue

{

get {return _listValue; }

set {_listValue = value; }

}



//Were are creating a member here so we can access it throughout the class

DropDownList _DDL;

DataGrid _DG;

FileStream fs;

StreamReader sr;

DataSet ds;

protected override void PreRender()

{

if (Page.IsPostBack) {

DataView dv = new DataView(ds.Tables[0]);

dv.RowFilter = listValue + "='" + _DDL.SelectedItem.Text + "'";

_DG = new DataGrid();

_DG.DataSource = dv;

_DG.DataBind();

Controls.Add(_DG);

}

}





protected override void CreateChildControls()

{

fs = new FileStream(Path, FileMode.Open, FileAccess.Read);

sr = new StreamReader(fs);

ds = new DataSet();

ds.ReadXml(sr);

fs.Close();



_DDL = new DropDownList();

_DDL.DataTextField = listText;

_DDL.DataValueField = listValue;

_DDL.AutoPostBack = true;

_DDL.DataSource = ds.Tables[0].DefaultView;

_DDL.DataBind();

Controls.Add(_DDL);





}

}

}



authors.xml

-------------------------------------------------------------



<schema id="DocumentElement" targetNamespace="" xmlns="http://www.w3.org/1999/XMLSchema"

xmlns:xdo="urn:schemas-microsoft-com:xml-xdo" xdo:DataSetName="DocumentElement">

    

        

            

            

            

            

            

            

            

            

            

        

        

            .

            au_id

        

    





    

        000-00-0000

        Doe

        John

        foo         

        One Microsoft Way

        Redmond

        CA

        98005

        True

    


    

        000-00-0123

        Millington

        John

        808 555-5555

        One Microsoft Way

        Redmond

        CA

        98005

        False

    


    

        172-32-1176

        White

        Johnson

        408 496-7223

        10932 Bigge Rd.

        Menlo Park

        CA

        94025

        True

    


    

        213-46-8915

        Green

        Marjorie

        415 986-7020

        309 63rd St. #411

        Oakland

        CA

        94618

        True

    


    

        238-95-7766

        Carson

        Cheryl

        415 548-7723

        589 Darwin Ln.

        Berkeley

        CA

        94705

        True

    


    

        267-41-2394

        O'Leary

        Michael

        408 286-2428

        22 Cleveland Av. #14

        San Jose

        CA

        95128

        True

    


    

        274-80-9391

        Straight

        Dean

        415 834-2919

        5420 College Av.

        Oakland

        CA

        94609

        True

    


    

        341-22-1782

        Smith

        Meander

        913 843-0462

        10 Mississippi Dr.

        Lawrence

        KS

        66044

        False

    


    

        409-56-7008

        Bennet

        Abraham

        415 658-9932

        6223 Bateman St.

        Berkeley

        CA

        94705

        True

    


    

        427-17-2319

        Dull

        Ann

        415 836-7128

        3410 Blonde St.

        Palo Alto

        CA

        94301

        True

    


    

        472-27-2349

        Gringlesby

        Burt

        707 938-6445

        PO Box 792

        Covelo

        CA

        95428

        True

    


    

        486-29-1786

        Locksley

        Charlene

        415 585-4620

        18 Broadway Av.

        San Francisco

        CA

        94130

        True

    


    

        527-72-3246

        Greene

        Morningstar

        615 297-2723

        22 Graybar House Rd.

        Nashville

        TN

        37215

        False

    


    

        648-92-1872

        Blotchet-Halls

        Reginald

        503 745-6402

        55 Hillsdale Bl.

        Corvallis

        OR

        97330

        True

    


    

        672-71-3249

        Yokomoto

        Akiko

        415 935-4228

        3 Silver Ct.

        Walnut Creek

        CA

        94595

        True

    


    

        712-45-1867

        del Castillo

        Innes

        615 996-8275

        2286 Cram Pl. #86

        Ann Arbor

        MI

        48105

        True

    


    

        722-51-5454

        DeFrance

        Michel

        219 547-9982

        3 Balding Pl.

        Gary

        IN

        46403

        True

    


    

        724-08-9931

        Stringer

        Dirk

        415 843-2991

        5420 Telegraph Av.

        Oakland

        CA

        94609

        False

    


    

        724-80-9391

        MacFeather

        Stearns

        415 354-7128

        44 Upland Hts.

        Oakland

        CA

        94612

        True

    


    

        756-30-7391

        Karsen

        Livia

        415 534-9219

        5720 McAuley St.

        Oakland

        CA

        94609

        True

    


    

        807-91-6654

        Panteley

        Sylvia

        301 946-8853

        1956 Arlington Pl.

        Rockville

        MD

        20853

        True

    


    

        846-92-7186

        Hunter

        Sheryl

        415 836-7128

        3410 Blonde St.

        Palo Alto

        CA

        94301

        True

    


    

        893-72-1158

        McBadden

        Heather

        707 448-4982

        301 Putnam

        Vacaville

        CA

        95688

        False

    


    

        899-46-2035

        Ringer

        Anne

        801 826-0752

        67 Seventh Av.

        Salt Lake City

        UT

        84152

        True

    


    

        998-72-3567

        Ringer

        Albert

        801 826-0752

        67 Seventh Av.

        Salt Lake City

        UT

        84152

        True

    


    

        999-99-9999

        Toe

        John

        808 444-4444

        21 Microsoft Way

        Redwood

        CA

        98005

        False

    








相关阅读 Windows错误代码大全 Windows错误代码查询激活windows有什么用Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Windows QQ聊天记录Windows 10自动更新怎么关闭 如何关闭Windows 10自动更新windows 10 rs4快速预览版17017下载错误问题Win10秋季创意者更新16291更新了什么 win10 16291更新内容windows10秋季创意者更新时间 windows10秋季创意者更新内容kb3150513补丁更新了什么 Windows 10补丁kb3150513是什么

文章评论
发表评论

热门文章 360快剪辑怎么使用 36金山词霸如何屏幕取词百度收购PPS已敲定!3

最新文章 微信3.6.0测试版更新了微信支付漏洞会造成哪 360快剪辑怎么使用 360快剪辑软件使用方法介酷骑单车是什么 酷骑单车有什么用Apple pay与支付宝有什么区别 Apple pay与贝贝特卖是正品吗 贝贝特卖网可靠吗

人气排行 xp系统停止服务怎么办?xp系统升级win7系统方电脑闹钟怎么设置 win7电脑闹钟怎么设置office2013安装教程图解:手把手教你安装与qq影音闪退怎么办 QQ影音闪退解决方法VeryCD镜像网站逐个数,电驴资料库全集同步推是什么?同步推使用方法介绍QQ2012什么时候出 最新版下载EDiary——一款好用的电子日记本