2016-09-20 56 views
0

當我點擊按鈕數據中的選擇按鈕填寫具有特定ID的窗體上,但我設置窗體禁用我的意思是沒有字段是可編輯的,因爲我想用戶點擊編輯按鈕比數據的形式已啓用並且用戶可以編輯。但是,當點擊編輯按鈕其清除所有領域當點擊編輯按鈕數據消失

請幫助我,我被卡住

這是我的編輯按鈕代碼

protected void btnEDIT_Click(object sender, EventArgs e) 
{ 
    txt_ID.Enabled = false; 
    TextBoxPN.Enabled = true; 
    TextBoxCP.Enabled = true; 
    TextBoxCUR.Enabled = true; 
    TextBoxMIN.Enabled = true; 
    Catogary_drop.Enabled = true; 
    Vnder_Drop.Enabled = true; 
    Sattus_Drop.Enabled = true; 
    TextBoxRMKS.Enabled = true; 


    btnADD.Enabled = false; 
    btnCLSE.Enabled = true; 
    btnCNCL.Enabled = true; 
    btnEDIT.Enabled = false; 
    btnUPD.Enabled = true; 

} 

這是我Gridiew選擇指數代碼

protected void GridViewitem_SelectedIndexChanged(object sender, EventArgs e) 
{ 
    GridViewRow row = GridViewitem.SelectedRow; 
    txt_ID.Text = row.Cells[1].Text; 
    TextBoxPN.Text=row.Cells[2].Text; 
    TextBoxCP.Text=row.Cells[3].Text; 
    TextBoxCUR.Text=row.Cells[4].Text; 
    TextBoxMIN.Text=row.Cells[5].Text; 
    Catogary_drop.Text = row.Cells[6].Text; 
    Vnder_Drop.Text = row.Cells[7].Text; 
    Sattus_Drop.Text = row.Cells[8].Text; 
    TextBoxRMKS.Text=row.Cells[9].Text; 

    txt_ID.Enabled = false; 
    TextBoxPN.Enabled = false; 
    TextBoxCP.Enabled = false; 
    TextBoxCUR.Enabled = false; 
    TextBoxMIN.Enabled = false; 
    Catogary_drop.Enabled = false; 
    Vnder_Drop.Enabled = false; 
    Sattus_Drop.Enabled = false; 
    TextBoxRMKS.Enabled = false; 

    btnADD.Enabled = false; 
    btnCLSE.Enabled = true; 
    btnCNCL.Enabled = true; 
    btnEDIT.Enabled = true; 
    btnUPD.Enabled = false; 
} 

回答

1

IsPostback Check Page_Load事件可能會對您有所幫助。或者您需要在點擊編輯按鈕時禁用回發。