Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
hi i had databind in gridview in asp.net .. when i click edit button... i need particular row value assign to textbox.... use javascript... plz helpme
Posted
Updated 3-Jan-12 21:56pm
v2

1. add attribute on edit button on rowdatabound event of gridview

2. send parameter button client id and one hidden field client id and grid view client id

3. find rows.count in js function and use for loop

4. find value of hidden field which stores index of row.

5. in loop, compare i and row index. and do every thing which you want.

if you have any confusion then tell me.
 
Share this answer
 
Comments
bprakash2 4-Jan-12 2:20am    
still getting confuse.. plz send me example code.
Hi, change your code with my code:

At RowDataBound

C#
TextBox txtInvDate = (TextBox)e.Row.FindControl("txtInvDate");
txtInvDate.Attributes.Add("onclick", "javascript:testJS('" + txtInvDate.ClientID + "');");


Write JS function(example)
JavaScript
function testJS(txtID)
{
var rowCount = document.getElementById('<%=grdCC.ClientID %>').rows.length;
            var grdElement = document.getElementById('<%=grdCC.ClientID %>')
for (var i = 1; i < rowCount; i++) {
  // Find here grid view controls. and write code on them.
}
}
 
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