Javascript获取DataGridview特定行 [英] Javascript Get DataGridview particular row

查看:69
本文介绍了Javascript获取DataGridview特定行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在asp.net的gridview中有数据绑定..当我单击编辑"按钮...我需要将特定的行值分配给文本框....使用javascript ... plz helpme

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

推荐答案

1.在gridview的rowdatabound事件上的编辑按钮上添加属性

2.发送参数按钮客户端ID和一个隐藏字段客户端ID和网格视图客户端ID

3.在js函数中找到rows.count并用于循环

4.查找存储行索引的隐藏字段的值.

5.循环比较i和行索引.并做你想做的每件事.

如有疑问,请告诉我.
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.


用我的代码更改代码:

在RowDataBound

Hi, change your code with my code:

At RowDataBound

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



编写JS函数(示例)



Write JS function(example)

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.
}
}


这篇关于Javascript获取DataGridview特定行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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