Click here to Skip to main content
15,948,339 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

C#
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;
}


plz give me d best solution...
thnx in advance...
Posted
Updated 4-Jul-11 0:42am
v3
Comments
Sunasara Imdadhusen 4-Jul-11 6:38am    
added PRE tag
kunalsobti89@yahoo.com 4-Jul-11 6:56am    
STILL GETTIN SAME PROBLEM
Sunasara Imdadhusen 4-Jul-11 6:46am    
Please provide .aspx page code for btnRese and GridViewExpense!!
kunalsobti89@yahoo.com 4-Jul-11 7:04am    
i have already provided above... plz note Reset button is html control
Sunasara Imdadhusen 4-Jul-11 7:17am    
then how to know your button to reset text from which textbox?

1 solution

This is Tricks you may apply.
aspx.cs
C#
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
C#
function btnReset_onclick() {
var currentTextbox = document.getElementById("<%= txthidden.ClientID %>").value;
document.getElementById(currentTextbox).value ="";
}

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


Thanks,
Imdadhusen
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900