点击编辑按钮数据时消失

时间:2016-09-20 06:25:31

标签: asp.net gridview webforms

当我点击按钮数据中的选择按钮填写具有特定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;

}

这是我的网格选择索引代码

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 个答案:

答案 0 :(得分:1)

IsPostback 签入Page_Load事件可能会对您有所帮助。或者您需要在编辑按钮单击时禁用回发。