2011-12-14 37 views
2

我想火网格视图的选择的指数变化的事件上点击它就像我一整排火上点击

的任何部分,一整排的任何部分网格视图的选择的指数变化情况不用想显示选择命令,而不是用户可以单击某一行的任何部分指的是行的任何列并获得选择

任何帮助表示赞赏

+2

看到http://www.geekzilla.co .uk/view9FC28EE6-ACB0-4F51-BFE4-38B0B10134D5.htm – VinayC 2011-12-14 11:19:13

回答

5

你不是已经提供的语言,行,所以我会告诉你一个VB.NET的例子(易于转换为C#):

处理的RowCreated事件在GridView的方式如下:

Private Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated 
    Select Case e.Row.RowType 
     Case DataControlRowType.DataRow 
      e.Row.Attributes("onmouseover") = "this.style.cursor='pointer';this.style.textDecoration='underline';" 
      e.Row.Attributes("onmouseout") = "this.style.textDecoration='none';" 
      e.Row.ToolTip = "Click to select row" 
      e.Row.Attributes("onclick") = Me.Page.ClientScript.GetPostBackClientHyperlink(DirectCast(sender,GridView), "Select$" & e.Row.RowIndex) 
    End Select 
End Sub 

的重要行是:

e.Row.Attributes("onclick") = Me.Page.ClientScript.GetPostBackClientHyperlink(DirectCast(sender, GridView), "Select$" & e.Row.RowIndex) 

C#

e.Row.Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink((GridView)sender, "Select$" + e.Row.RowIndex) 
+0

另一种替代方法是在一行中有一个隐藏的选择按钮,并在单击行时触发按钮单击。 – VinayC 2011-12-14 11:18:54