在行的单击上选择gridview的行 [英] select the row of gridview on the click of row

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

问题描述

我想在网格视图中单击该行的任意位置来选择一行.

这样我就可以捕获Gridview的索引.

我已经在Gridview中使用RowDataBound

I want to select a row on clicking anywhere on the row in grid view.

So i can capture the index of the Gridview.

I have used in Gridview RowDataBound

If (e.Row.RowType = DataControlRowType.DataRow) Then
           e.Row.Attributes.Add("onmouseover", "this.style.cursor='hand';this.style.textDecoration='underline';")
           e.Row.Attributes.Add("onmouseout", "this.style.textDecoration='none';")

           e.Row.Attributes.Add("onclick", ClientScript.GetPostBackClientHyperlink(Me.gvDrugs, "Select$" + e.Row.RowIndex.ToString()))
           Dim str As String
           str = e.Row.RowIndex.ToString()


加载时没有问题..

当Gridview出现并且我单击GridView行时,它将引发异常


while loading there is no problem..

When the Gridview is appeared and i click on the GridView row it throws exception

Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation. 



所以我在页面指令中添加了



So i added In page Directive

AutoEventWireup="false"  
EnableEventValidation="false"




但是仍然出现相同的错误.

我想在网格中单击行时捕获(来自数据库的ID)


谁能帮我.


谢谢
yashoda
[edit]代码块添加,一些小调整-OriginalGriff [/edit]




But still getting the same error.

I want to capture the (id that comes from the database) on the click of the row in the grid


Can any one help me.


Thank you,
yashoda
[edit]Code blocks adde, some minor tweaks - OriginalGriff[/edit]

推荐答案

" + e.Row.RowIndex.ToString())) Dim str As 字符串 str = e.Row.RowIndex.ToString()
" + e.Row.RowIndex.ToString())) Dim str As String str = e.Row.RowIndex.ToString()


加载时没有问题..

当Gridview出现并且我单击GridView行时,它将引发异常


while loading there is no problem..

When the Gridview is appeared and i click on the GridView row it throws exception

Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation. 



所以我在页面指令中添加了



So i added In page Directive

AutoEventWireup="false"  
EnableEventValidation="false"




但是仍然出现相同的错误.

我想在网格中单击行时捕获(来自数据库的ID)


谁能帮我.


谢谢
yashoda
[edit]代码块添加,还有一些细微调整-OriginalGriff [/edit]




But still getting the same error.

I want to capture the (id that comes from the database) on the click of the row in the grid


Can any one help me.


Thank you,
yashoda
[edit]Code blocks adde, some minor tweaks - OriginalGriff[/edit]


如果要在datagridview的任何单元格上单击以选择整行,则可以非常简单地实现. br/>
单击datagridview转到其属性,然后将SelectionMode设置为FullRowSelect.


现在将选择整行而不是仅标题.
If you want to select full row on click any cell of the datagridview, you can do it very simply.

Click on the datagridview Go to its Properties and Set The SelectionMode to FullRowSelect.


Now full row will be selected instead of only header.


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

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