从datagridview选择一行 [英] Selecting a row from a datagridview

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

问题描述

我有一个datagridview,其中有一个需要被选中的列,例如超链接.它需要看起来像超链接,但是在没有重定向到新页面的情况下,我只希望它读取该行,使用数据并拉出另一个表以显示更多信息.我一直找不到合适的教程来正确地解释如何处理这个问题,我真的希望我能在这里得到一些帮助.如果有人有一些有用的提示,我将不胜感激.

在此先感谢
Sean8084

I''ve got a datagridview which has a column that I need to be able to be selected, something like a hyperlink. it needs to look like a hyperlink, but with out redirecting to a new page, I just want it to read that row, use the data, and pull another table to display more information. I''ve not been able to find any good tutorials that rightly explain how to handle this and was really hoping that I could get some assistance here. if anyone has some helpful tips, I would greatly appreciate it.

Thanks in Advance
Sean8084

推荐答案

为您的解决方案..
1)您需要在gridview中放置一个模板,
2)在该模板字段的项目模板中,您需要放置一个链接按钮控件.
3)然后,您需要在链接按钮上添加一个命令参数属性,该属性对于将在网格中显示的所有记录都是唯一的..

4)在该链接按钮的gridviews项目单击事件上,您需要编写所需的代码.

这不会重定向到您的新页面...
for your solution..
1) you need to put a template filed in your gridview,
2)in that template field''s, item template you need to put a link button control.
3)then you need to add a command argument property to your link button that will be unique for all record that will be shown in your grid..

4) on the gridviews item click event of that link button you need to write your code what you want..

this will be not redirect to you new page...


我还没有完全做到这一点,但是我可以提出一个想法.

将数据绑定到GridView时,可以轻松地将其格式化为超链接.在"OnClick"事件上,将JS调用包含到该锚标记中.因此,您可以在客户端选择事件.然后通过AJAX调用获取要显示的其余数据.
I haven''t done exactly this, but I can give an idea.

When you are binding data to the GridView, you can formatted it as a hyperlink easily. Include a JS invoke into that anchor tags on ''OnClick'' event. So you can pick the event on client side. Then through an AJAX call get rest of the data that you want to display.


这篇关于从datagridview选择一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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