熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

使用ASP.Net中的自定義控件[2]

2022-06-13   來源: .NET編程 
    ——此文章摘自《ASPNET網絡數據庫開發實例精解》定價 特價 詳細>>

    // <summary>
    // 設置控件的事件OnCheckChanged
    // </summary>
    private void OnCheckChanged(object sender EventArgs e)
    {
    if (CheckedChanged != null){CheckedChanged(sender e);}
    }
    // <summary>
    //定義控件的屬性Name
    // </summary>
    private string name;
    public string Name
    {
    get{return(name);}
    set{name = value;}
    }
    // <summary>
    // 定義控件的屬性DataField
    // </summary>
    private string dataField;
    public string DataField
    {
    get{return dataField;}
    set{dataField=value;}
    }
    // <summary>
    // 定義控件的屬性AutoPostback
    // </summary>
    private bool autoPostBack = false;
    public bool AutoPostBack
    {
    set{autoPostBack = value;}
    get{return autoPostBack;}
    }
    // <summary>
    // 定義控件的數據綁定函數BindData()
    // </summary>
    private void BindData(object sender EventArgs e)
    {
    //找到CheckBox控件
    CheckBox box = (CheckBox) sender;
    DataGridItem container = (DataGridItem) boxNamingContainer;
    boxChecked = false;
    boxEnabled = (readOnly == true) ? false:true;
    //獲取數據
    string data =
    ((DataRowView) containerDataItem)[dataField]ToString();
    //獲取數據類型
    Type t = ((DataRowView)containerDataItem)DataViewTableColumns[
    dataField]DataType;
    if (dataLength>)
    {
    switch (tToString())
    {   //設置控件的值
    case SystemBoolean:

[]  []  []  []  []  []  []  []  


From:http://tw.wingwit.com/Article/program/net/201311/15048.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.