我在页面上创建一个故障ID的时候,比如200605001,这个ID是自动生成的,当我刷新页面的时候,却自动的创建了
ID:200605002,请大家帮我解决这个问题,就是当我刷新的时候,不再创建了

解决方案 »

  1.   

    if(!IsPostBack)
    {
    ...
    }
      

  2.   

    if(!Page.IsPostBack)
    {
    datainput();
    }
    private void datainput()
    { imgUpFile.Visible=false;
    imgDownloadFile.Visible=false; this.txday1.Attributes.Add("onkeyup","EnterKey(0,this,'');");
    this.txhour1.Attributes.Add("onkeyup","EnterKey(0,this,'');");
    this.txminutes1.Attributes.Add("onkeyup","EnterKey(0,this,'');"); this.txday2.Attributes.Add("onKeyup","EnterKey(0,this,'');");
    this.txhour2.Attributes.Add("onKeyup","EnterKey(0,this,'');");
    this.txminutes2.Attributes.Add("onKeyup","EnterKey(0,this,'');");
    this.txday1.Attributes.Add("onchange","Calculrate();");
    this.txhour1.Attributes.Add("onchange","Calculrate();");
    this.txminutes1.Attributes.Add("onchange","Calculrate();"); this.txday2.Attributes.Add("onchange","Calculrate();");
    this.txhour2.Attributes.Add("onchange","Calculrate();");
    this.txminutes2.Attributes.Add("onchange","Calculrate();");

    imgQry.Attributes.Add("onMouseOver","this.style.cursor='hand'");
    imgCreate.Attributes.Add("onMouseOver","this.style.cursor='hand'");
    imgEdit.Attributes.Add("onMouseOver","this.style.cursor='hand'");
    imgDel.Attributes.Add("onMouseOver","this.style.cursor='hand'");
    imgCardQry.Attributes.Add("onMouseOver","this.style.cursor='hand'");
    imgUpFile.Attributes.Add("onMouseOver","this.style.cursor='hand'");
                imgDownloadFile.Attributes.Add("onMouseOver","this.style.cursor='hand'");
    this.imgPrint.Attributes.Add("onMouseOver","this.style.cursor='hand'");

    this.imgCardQry.Attributes.Add("onclick","launchCenter('EqpCardQry.aspx','center', 460, 310)");
    //Javascript经典代码:JS事件确认进行

    imgEdit.Attributes.Add("onclick","javascript:__doPostBack('edit','');");
    imgDel.Attributes.Add("onclick","if(confirm('确实要删除吗?')) del();");
    //imgCreate.Attributes.Add("onclick","javascript:__doPostBack('create','');");和下面的一个语句的效果是相同的
    imgCreate.Attributes.Add("onclick","create();");
    imgQry.Attributes.Add("onclick","javascript:__doPostBack('qry','');");
    imgDel.Attributes.Add("onclick","javascript:__doPostBack('del','');"); imgUpFile.Attributes.Add("onclick","javascript:__doPostBack('upfile','');");

    string ss=this.txEqpNo3.Text.ToString()+'-'+this.txEqpNo1.Text.ToString()+'-'+this.txEqpNo2.Text.ToString();

    imgUpFile.Attributes.Add("onclick","launchCenter('multipleuploads.aspx?id="+ss+"','center', 290, 400)");
    this.imgDownloadFile.Attributes.Add("onclick","launchCenter('downloadaspx.aspx','center', 455, 325)");
    ///imgPrint.Attributes.Add("onclick","return Print();");//onclick","return Print();
    imgPrint.Attributes.Add("onclick","getPrint('bodydiv');");
    txdtlinehour.Attributes.Add("onKeyup","linedt();");
    txdtlineminute.Attributes.Add("onKeyup","linedt();");
    this.txbarrierNotime.Text=GetTimeNow();
    this.txbarrierdepart.Text="BF00";
    int year1 = DateTime.Now.Year;
    int month1 = DateTime.Now.Month;

    this.ddlmonth1.Items.Clear();
    this.ddlmonth1.Items.Insert(0,new ListItem("1","0"));
    this.ddlmonth1.Items.Insert(1,new ListItem("2","1"));
    this.ddlmonth1.Items.Insert(2,new ListItem("3","2"));
    this.ddlmonth1.Items.Insert(3,new ListItem("4","3"));
    this.ddlmonth1.Items.Insert(4,new ListItem("5","4"));
    this.ddlmonth1.Items.Insert(5,new ListItem("6","5"));
    this.ddlmonth1.Items.Insert(6,new ListItem("7","6"));
    this.ddlmonth1.Items.Insert(7,new ListItem("8","7"));
    this.ddlmonth1.Items.Insert(8,new ListItem("9","8"));
    this.ddlmonth1.Items.Insert(9,new ListItem("10","9"));
    this.ddlmonth1.Items.Insert(10,new ListItem("11","10"));
    this.ddlmonth1.Items.Insert(11,new ListItem("12","11"));

    this.ddlmonth2.Items.Insert(0,new ListItem("1","0"));
    this.ddlmonth2.Items.Insert(1,new ListItem("2","1"));
    this.ddlmonth2.Items.Insert(2,new ListItem("3","2"));
    this.ddlmonth2.Items.Insert(3,new ListItem("4","3"));
    this.ddlmonth2.Items.Insert(4,new ListItem("5","4"));
    this.ddlmonth2.Items.Insert(5,new ListItem("6","5"));
    this.ddlmonth2.Items.Insert(6,new ListItem("7","6"));
    this.ddlmonth2.Items.Insert(7,new ListItem("8","7"));
    this.ddlmonth2.Items.Insert(8,new ListItem("9","8"));
    this.ddlmonth2.Items.Insert(9,new ListItem("10","9"));
    this.ddlmonth2.Items.Insert(10,new ListItem("11","10"));
    this.ddlmonth2.Items.Insert(11,new ListItem("12","11"));
    this.ddlmonth1.Items.FindByText(month1.ToString()).Selected=true;
    this.ddlmonth2.Items.FindByText(month1.ToString()).Selected=true;

    //插入年份

    ddlyear1.Items.Insert(0,new ListItem((year1+1).ToString().Trim(),"0"));
    ddlyear1.Items.Insert(1,new ListItem(year1.ToString().Trim(),"1"));
    ddlyear1.Items.Insert(2,new ListItem((year1-1).ToString().Trim(),"2"));
    ddlyear1.Items.Insert(3,new ListItem((year1-2).ToString().Trim(),"3"));
    ddlyear1.Items.Insert(4,new ListItem((year1-3).ToString().Trim(),"4"));
    ddlyear1.Items.Insert(5,new ListItem((year1-4).ToString().Trim(),"5"));
    ddlyear2.Items.Insert(0,new ListItem((year1+1).ToString().Trim(),"0"));
    ddlyear2.Items.Insert(1,new ListItem(year1.ToString().Trim(),"1"));
    ddlyear2.Items.Insert(2,new ListItem((year1-1).ToString().Trim(),"2"));
    ddlyear2.Items.Insert(3,new ListItem((year1-2).ToString().Trim(),"3"));
    ddlyear2.Items.Insert(4,new ListItem((year1-3).ToString().Trim(),"4"));
    ddlyear2.Items.Insert(5,new ListItem((year1-4).ToString().Trim(),"5"));
    //显示当前年月
    this.ddlyear1.Items.FindByText(year1.ToString()).Selected=true;
    this.ddlyear2.Items.FindByText(year1.ToString()).Selected=true; ClDb db =new ClDb();
    string strSql="select * from department where substring(depcode,3,2)='00' and substring(depcode,1,1)<>'A' order by depname desc";

    db.BindDropDownList(ddlbarrierpart,"select * from commoncode where groupid='AA10'","itemname","itemid","");
    db.BindDropDownList(ddlreason,"select * from commoncode where groupid='AA11'","itemname","itemid","");
    db.BindDropDownList(ddlphenomenon,"select * from commoncode where groupid='AA12'","itemname","itemid","");
                db.BindDropDownList(ddldepart,strSql,"depname","depcode"," ");
    db.DBClose();
    }
      

  3.   

    不好意思,刚才代码太乱,整理以下
    private void datainput()
    {
    imgUpFile.Visible=false;
    imgDownloadFile.Visible=false;
    this.txday1.Attributes.Add("onkeyup","EnterKey(0,this,'');");
    this.txhour1.Attributes.Add("onkeyup","EnterKey(0,this,'');");
    this.txminutes1.Attributes.Add("onkeyup","EnterKey(0,this,'');"); this.txday2.Attributes.Add("onKeyup","EnterKey(0,this,'');");
    this.txhour2.Attributes.Add("onKeyup","EnterKey(0,this,'');");
    this.txminutes2.Attributes.Add("onKeyup","EnterKey(0,this,'');"); this.txday1.Attributes.Add("onchange","Calculrate();");
    this.txhour1.Attributes.Add("onchange","Calculrate();");
    this.txminutes1.Attributes.Add("onchange","Calculrate();"); this.txday2.Attributes.Add("onchange","Calculrate();");
    this.txhour2.Attributes.Add("onchange","Calculrate();");
    this.txminutes2.Attributes.Add("onchange","Calculrate();");

    imgQry.Attributes.Add("onMouseOver","this.style.cursor='hand'");
    imgCreate.Attributes.Add("onMouseOver","this.style.cursor='hand'");
    imgEdit.Attributes.Add("onMouseOver","this.style.cursor='hand'");
    imgDel.Attributes.Add("onMouseOver","this.style.cursor='hand'");
    imgCardQry.Attributes.Add("onMouseOver","this.style.cursor='hand'");
    imgUpFile.Attributes.Add("onMouseOver","this.style.cursor='hand'");
             imgDownloadFile.Attributes.Add("onMouseOver","this.style.cursor='hand'");
    this.imgPrint.Attributes.Add("onMouseOver","this.style.cursor='hand'");

    this.imgCardQry.Attributes.Add("onclick","launchCenter('EqpCardQry.aspx','center', 460, 310)");


    imgEdit.Attributes.Add("onclick","javascript:__doPostBack('edit','');");
    imgDel.Attributes.Add("onclick","if(confirm('确实要删除吗?')) del();");

    imgCreate.Attributes.Add("onclick","create();");
    imgQry.Attributes.Add("onclick","javascript:__doPostBack('qry','');");
    imgDel.Attributes.Add("onclick","javascript:__doPostBack('del','');"); imgUpFile.Attributes.Add("onclick","javascript:__doPostBack('upfile','');");

    string ss=this.txEqpNo3.Text.ToString()+'-'+this.txEqpNo1.Text.ToString()+'-'+this.txEqpNo2.Text.ToString();
    imgUpFile.Attributes.Add("onclick","launchCenter('multipleuploads.aspx?id="+ss+"','center', 290, 400)");
    this.imgDownloadFile.Attributes.Add("onclick","launchCenter('downloadaspx.aspx','center', 455, 325)"); imgPrint.Attributes.Add("onclick","getPrint('bodydiv');");
    txdtlinehour.Attributes.Add("onKeyup","linedt();");
    txdtlineminute.Attributes.Add("onKeyup","linedt();");
    this.txbarrierNotime.Text=GetTimeNow();
    this.txbarrierdepart.Text="BF00";
    ClDb db =new ClDb();
    string strSql="select * from department where substring(depcode,3,2)='00' and substring(depcode,1,1)<>'A' order by depname desc";

    db.BindDropDownList(ddlbarrierpart,"select * from commoncode where groupid='AA10'","itemname","itemid","");
    db.BindDropDownList(ddlreason,"select * from commoncode where groupid='AA11'","itemname","itemid","");
    db.BindDropDownList(ddlphenomenon,"select * from commoncode where groupid='AA12'","itemname","itemid","");
    db.BindDropDownList(ddldepart,strSql,"depname","depcode"," ");
    db.DBClose();
    }