如何在动态网格视图中获取当前行值 [英] How to get current row value in Dynamic gridview

查看:83
本文介绍了如何在动态网格视图中获取当前行值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



这里我的问题是我不知道如何在动态gridview中获取当前行值,

i请参考此链接



动态添加和删除行ASP.NET GridView [ ^ ]



例如:



这里我使用动态gridview,用户可以在gridview中添加和删除更多行,每行我使用列名(数量),如果客户端总共添加两行并且他们点击第一行图像(imagebutton)我想显示弹出他们输入的是什么数量栏,它类似第二排,



怎么做..



谢谢!

解决方案

您可以使用 GridView1.SelectedRow 属性 OnSelectedIndexChanged 事件发生在 GridView



检查以下教程



http://aspsnippets.com/Articles/How-to-get-Selected-Row-cell-value-from-GridView-in-ASPNet.aspx [ ^ ]


您可以为 ImageButton 指定 CommandName 属性。

同样声明 CommandArgument 属性如...

 CommandArgument =<%#((GridViewRow)容器).RowIndex%>



然后在<$ c $里面c> RowCommand 事件,检查 CommandName 并获取行的详细信息,如...

  int  index = Convert.ToInt32(e.CommandArgument); 

// 检索包含点击按钮的行
用户从Rows集合中 //
GridViewRow row = ProductsGridView.Rows [index];



完整示例 - GridView.RowCommand Event [ ^ ]


Hi
Here my problem is i don't know how to get current row value in dynamic gridview,
i refer this link

Dynamically adding and deleting rows from ASP.NET GridView[^]

For Example:

here i using dynamic gridview, user can add and remove more row in gridview, each row i use column name(quantity), if client add totally two rows and they click first row image(imagebutton) i want to show popup what they are enter in no of quantity column, it similar like second row,

how to do that..

Thank You !

解决方案

You can use GridView1.SelectedRow property when OnSelectedIndexChanged event occures in the GridView

Check below tutorial

http://aspsnippets.com/Articles/How-to-get-Selected-Row-cell-value-from-GridView-in-ASPNet.aspx[^]


You can have a CommandName property specified for the ImageButton.
Also declare CommandArgument property like...

CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"


Then inside the RowCommand Event, check the CommandName and get the details of the Row like...

int index = Convert.ToInt32(e.CommandArgument);

// Retrieve the row that contains the button clicked 
// by the user from the Rows collection.      
GridViewRow row = ProductsGridView.Rows[index];


Complete example at - GridView.RowCommand Event[^]


这篇关于如何在动态网格视图中获取当前行值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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