使GridView可点击 [英] Making GridView Clickable

查看:95
本文介绍了使GridView可点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果有人可以修改以下代码以便GridView变得可点击,我会很高兴。问题是所讨论的代码在我的Windows应用程序中在DataGridView的CellMouseClick事件下完美地工作,但它在Web应用程序中不起作用,因为其中没有这样的事件。那么,在什么情况下可以点击?







 尝试 
dr = 没什么
Dim str 作为 字符串
str = GridView1.SelectedValue(< span class =code-digit> 0 )。值
cmd = SqlCommand( 从ProgramDetails.Subjects中选择*,其中SubjectCode ='& str& ',cn)
dr = cmd.ExecuteReader
while (博士。阅读)
txtIdNumber.Text = dr( 0
txtSubjectCode.Text = dr( 1
txtSubjectName.Text = dr( 2
如果 dr( 3 )= 核心 然后
rbnCore.Checked = True
其他
rbnElective .Checked = True
结束 如果
txtUserId.Text = dr( 4
txtPassword.Text = dr( 5
结束 虽然
dr.Close()
btnSave.Enabled = False
Catch ex 例外
结束 尝试

解决方案

< blockquote>你无法使用AutoSelectColumn&为事件SelectedIndex更改编写代码。

这样就显示了额外的列来选择网格视图行。



您也可以使用以下链接来做这不使用AutoselectColumn属性&使完整的行可点击。但我从未尝试过这个。



http://www.velocityreviews.com/forums/t120857-select-gridview-row-without-using-select-button.html [ ^ ]



https://groups.google.com/forum/?hl=en&fromgroups=#!topic/microsoft.public.dotnet.framework.aspnet.webcontrols/6d4pWmz2c10 [ ^ ]


您需要使用模板进行编辑更新&删除



请使用以下链接



ASP.NET 2.0中的可编辑GridView [ ^ ]



< a href =http://www.codeproject.com/Articles/16769/Full-featured-Editable-GridView-Control>功能齐全的可编辑GridView控件 [ ^ ]


I''d be glad if someone could kindly modify the following code so that GridView becomes click-able. The problem is that the code in question works perfectly in my Windows application under CellMouseClick Event of DataGridView but it doesn''t work in the Web application since there''s no such event therein. So, under what event can it be made click-able?



Try
        dr = Nothing
        Dim str As String
        str = GridView1.SelectedValue(0).Value
        cmd = New SqlCommand("Select* from ProgramDetails.Subjects where SubjectCode='" & str & "'", cn)
        dr = cmd.ExecuteReader
        While (dr.Read)
            txtIdNumber.Text = dr(0)
            txtSubjectCode.Text = dr(1)
            txtSubjectName.Text = dr(2)
            If dr(3) = "Core" Then
                rbnCore.Checked = True
            Else
                rbnElective.Checked = True
            End If
            txtUserId.Text = dr(4)
            txtPassword.Text = dr(5)
        End While
        dr.Close()
        btnSave.Enabled = False
    Catch ex As Exception
    End Try

解决方案

You can unable AutoSelectColumn & write code for event SelectedIndex Change.
So that extra column shown to select grid view row.

You can also use below links to do this without using AutoselectColumn property & make complete row click able. But I never tried this.

http://www.velocityreviews.com/forums/t120857-select-gridview-row-without-using-select-button.html[^]

https://groups.google.com/forum/?hl=en&fromgroups=#!topic/microsoft.public.dotnet.framework.aspnet.webcontrols/6d4pWmz2c10[^]


You needs to use Templates for edit update & delete

Please use belowlinks

Editable GridView in ASP.NET 2.0[^]

Full-featured Editable GridView Control[^]


这篇关于使GridView可点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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