您的位置:程序门 -> .net技术 -> asp.net



dropdownlist取值


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


dropdownlist取值
发表于:2007-07-16 13:40:08 楼主
用到了母版页后
dropdownlist.selectitem.text取的值永远都是第一个
请问
这个如何解决
发表于:2007-07-16 13:42:041楼 得分:0
dropdownlist在master   page还是conetent   page?
请看看这篇文章:http://www.cnblogs.com/doll-net/archive/2007/07/16/819553.html
发表于:2007-07-16 13:55:182楼 得分:0
在conetent   page里面的dropdownlist
发表于:2007-07-16 13:57:253楼 得分:0
那你pageload里是否绑定dropdownlist
如果是,看看有没有进行ispostback判断,否则,请贴出你的逻辑说明和相关code
发表于:2007-07-16 13:58:554楼 得分:0
conetent   page
using   system;
using   system.data;
using   system.configuration;
using   system.collections;
using   system.web;
using   system.web.security;
using   system.web.ui;
using   system.web.ui.webcontrols;
using   system.web.ui.webcontrols.webparts;
using   system.web.ui.htmlcontrols;

public   partial   class   admin_adduser   :   system.web.ui.page
{
        dbconnection   db   =   new   dbconnection();
        string   username   =   " ";
        string   userpwd   =   " ";
        string   sex   =   " ";
        string   dept   =   " ";
        string   email   =   " ";
        string   mobile   =   " ";
        string   officetel   =   " ";
        int   userid   =   0;

        protected   void   page_load(object   sender,   eventargs   e)
        {
                getdept();
                getmaxitemnum();
        }

        private   void   getdept()
        {
                string   sql_dept   =   "select   dept_id,dept_name   from   dc_department ";
                dataset   ds   =   db.db_createdataset(sql_dept);
                ddldept.datasource   =   ds.tables[0];
                ddldept.datatextfield   =   "dept_name ";
                ddldept.datavaluefield   =   "dept_id ";
                ddldept.databind();
        }

        private   void   getmaxitemnum()
        {
                string   sql_itemnumber   =   "select   max(convert(int,user_id))   from   dc_user ";
                system.data.dataset   ds_itemnumber   =   db.db_createdataset(sql_itemnumber);
                userid   =   convert.toint32(ds_itemnumber.tables[0].rows[0][0]);
                db.close();
        }
        protected   void   imgok_click(object   sender,   imageclickeventargs   e)
        {
                username   =   this.txtusername.text.trim();
                userpwd   =   this.txtuserpwd.text.trim();
                sex   =   this.rblsex.selectedvalue.tostring();
                dept   =   this.ddldept.selecteditem.value;
                email   =   this.txtemail.text.trim();
                mobile   =   this.txtmobile.text.trim();
                officetel   =   this.txtofficetel.text.trim();
                userid   =   userid+1;

                string   sql   =   "insert   into   dc_user   (user_id,user_name,sex,dept_id,password,email,mobile,officetel)   values   ( ' "   +   userid   +   " ', ' "   +   username   +   " ', ' "   +   sex   +   " ', ' "   +   dept   +   " ', ' "   +   userpwd   +   " ', ' "   +   email   +   " ', ' "   +   mobile   +   " ', ' "   +   officetel   +   " ') ";
                db.db_EXECutenonquery(sql);
                db.close();
               
        }
}
发表于:2007-07-16 14:02:265楼 得分:0
protected   void   page_load(object   sender,   eventargs   e)
{
      if(!ispostback)
      {
                getdept();
      }
      getmaxitemnum();
}


快速检索

最新资讯
热门点击