——此文章摘自《ASPNET +SQL Server网络应用系统开发案例精解》定价¥特价¥ 详细>>http://tracklinktechcn/?m_id=dangdang&a_id=A&l=&l_type= width= height= border= nosave> </TR> </TABLE> </FONT> </TD> </TR> </TABLE> <uc:stfooter id=STFooter runat=server></uc:stfooter> .STUserDepaspxcs的主要代码及其解释 STUserDepaspxcs主要代码实现了查看自己连锁店信息的功能页面进行初始化时通过调用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() { STconnOpen(); //创建查询连锁店信息的sql语句 string STstrsql=select STDep* from STDepSTUser where STDepSTDepID = STUserSTDepID; //创建数据库的SqlCommand对象 SqlCommand STcmd = new SqlCommand(STstrsqlSTconn); //创建SqlCommand对象的ExecuteReader()方法用来读取数据 SqlDataReader STsdr = STcmdExecuteReader(); while(STsdrRead()) { //将连锁店ID保存到会话中 Session[STDepID] = STsdr[STDepID]; //STDepID文本框得到连锁店ID STDepIDText = Session[STDepID]ToString(); Session[STDepName] = STsdr[STDepName]; STDepNameText = Session[STDepName]ToString(); Session[STDepMaster] = STsdr[STDepMaster]; STDepMasterText = Session[STDepMaster]ToString(); Session[STDepInfo] = STsdr[STDepInfo]; STDepInfoText = Session[STDepInfo]ToString(); } } right>[http://developcsaicn/dotnet_ASP/htm>] [] |