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

連鎖中心配送系統:分店用戶管理信息查看[2]

2013-11-13 11:51:44  來源: .NET編程 
    ——此文章摘自《ASPNET +SQL Server網絡應用系統開發案例精解》定價 特價 詳細>>http://tracklinktechcn/?m_id=dangdang&a_id=A&l=&l_type= width= height= border= nosave>

                                         </asp:DataGrid></FONT></TD>
             </TR>
             </TABLE>
             <uc:stfooter id=STFooter runat=server></uc:stfooter>

    .STUserInfoaspx的主要代碼及其解釋

    STUserInfoaspx實現了查看自己信息的功能頁面進行初始化時通過調用BindGrid()方法來從數據庫中獲取用戶信息填充DataGrid控件主要代碼及其解釋如下
    private void Page_Load(object sender SystemEventArgs e)
    {
             if(Session[STNickName] != null)
             {
                       //獲得數據庫連接字符串
                       string STconnection = ConfigurationSettingsAppSettings[strconnection];
                       //創建數據庫連接
                       STconn = new SqlConnection(STconnection);
                       if(!IsPostBack)
                       {
                                //自定義ST_DgBind()方法加載用戶的信息
                                BindGrid();
                       }
             }
             else
             {
                       ResponseRedirect(/Indexaspx);
             }
    }
    //加載用戶的信息
    public void BindGrid()
    {
             //獲取登錄用戶的登錄名
             string STNickName = Session[STNickName]ToString();
             //根據登錄用戶名和管理權限創建查詢用戶所有信息的sql語句
             string STstrsql=select STUserIDSTNickNameSTUserNameSTNoAdmin from STUser where STNickName = +STNickName + and STNoAdmin = ;
             //創建SqlDataAdapter的實例
             SqlDataAdapter STsda=new SqlDataAdapter(STstrsqlSTconn);
             //創建DataSet的實例
             DataSet STds=new DataSet();
             //將信息填充到DataSet
             STsdaFill(STds);
             //將信息綁定到DataGrid
             STmyGridDataSource = STds;
           
             STmyGridDataBind();
    }

right>[http://developcsaicn/dotnet_ASP/htm>]  []  


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