如何清除JavaScript中包含gridview行编辑值的文本框 [英] How to clear textbox in javascript that contains value of gridview row editing

查看:76
本文介绍了如何清除JavaScript中包含gridview行编辑值的文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VS2010.
我有以下Asp控件,一个文本框和一个gridview,一个更新和html Reset按钮.
当我单击gridview行的行编辑按钮时,它将在文本框中填充相应的值.我的问题是,当我单击重置"按钮时,它不会清除来自gridview行的文本框值.

hi i m using VS 2010 .
i have following Asp controls one textbox and one gridview and one update and html Reset button.
when i click on row editing button of gridview row then it fills the corresponding value in textbox. my problem is that when i click on reset button it does not clear textbox value that comes from gridview row.

function btnReset_onclick() {
 document.getElementById("<%= txtDescription.ClientID %>").value = "";
}



protected void GridViewExpenses_RowEditing(object sender, GridViewEditEventArgs e)
{
         lblExpenseDesc = GridViewExpenses.Rows[e.NewEditIndex].FindControl("lblDescription") as Label;
         txtDescription.Text = lblExpenseDesc.Text;
}



请给我最好的解决方案...
提前thnx ...



plz give me d best solution...
thnx in advance...

推荐答案

这是您可以应用的技巧.
aspx.cs
This is Tricks you may apply.
aspx.cs
protected void GridViewExpenses_RowEditing(object sender, GridViewEditEventArgs e)
{
         //You need to set client id of currently active textbox
         TextBox txt = GridViewExpenses.Rows[e.NewEditIndex].FindControl("txtDescription") as TextBox;
         txthidden.value = txt.ClientID;
}


.aspx


.aspx

function btnReset_onclick() {
var currentTextbox = document.getElementById("<%= txthidden.ClientID %>").value;
document.getElementById(currentTextbox).value ="";
}


<asp:HiddenField  runat="server" id="txthidden"/>



谢谢,
Imdadhusen



Thanks,
Imdadhusen


这篇关于如何清除JavaScript中包含gridview行编辑值的文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆