.net 2005 GridView 控件的选择行问题.

来源:百度知道 编辑:UC知道 时间:2024/05/15 18:41:24
GridView控件加了选择列,单击"选择"可以选择某一列.

但我现在想单击一行中的任意位置都可以选择一行,并不只单单限制必须点击"选择"列.

看了你的问题于是我试了一下,好象目前没有现成的方法实现,不过我试了下用如下两个方法是没问题的
一,你可以把所有把所有列都用选择列来绑定,就是把这每一列的选择键Text值绑定到你要显示的字段,这个方法好理解:)

<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Select" Text='<%# Bind("email") %>'></asp:LinkButton>
</ItemTemplate>
二,根据查看客户端HTML来分析,我们会看到选择列里的HTML代码是象下面这个样子<a id="GridView1_ctl05_LinkButton1" href="javascript:__doPostBack('GridView1$ctl05$LinkButton1','')">选择</a>实际调用了系统生成的一个JAVASCRIPT函数<script type="text/javascript">
<!--
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;