如何在rowcommand事件上访问子gridview? [英] How do I access child gridview on rowcommand event?

查看:49
本文介绍了如何在rowcommand事件上访问子gridview?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我还是新手使用Vb.net,它非常容易处理主gridview rowcommand事件。但是,我仍然不知道如何访问子gridview行命令。每当我使用关键字'AddHandler gvFiles.RowCommand,AddressOf gvFiles_RowCommand'时,它将导致错误'没有与委托兼容的签名'代码如下。



Hi y'all,

I'm still new on using Vb.net and its pretty easy to handle the main gridview rowcommand event. However, i still dont know how to access the child gridview row command. whenever I use the keyword 'AddHandler gvFiles.RowCommand, AddressOf gvFiles_RowCommand' it will cause an error 'does not have signature compatible with delegate' The codes are as below.

Private Sub GridView1_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GridView1.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim lbltype As Label = e.Row.FindControl("lblType_HWSW")
            Dim LinkCalendar As LinkButton = e.Row.FindControl("LinkCalendar")

            If (lbltype.Text = "sw") Then
                LinkCalendar.Visible = False
            End If

            Dim filePaths() As String = Directory.GetFiles(("C:\Uploads"))
            Dim files As List(Of ListItem) = New List(Of ListItem)
            For Each filePath As String In filePaths
                files.Add(New ListItem(Path.GetFileName(filePath), filePath))
            Next

            Dim gvFiles As GridView = e.Row.FindControl("GridView2")
            AddHandler gvFiles.RowCommand, AddressOf gvFiles_RowCommand 'this line is causing me an error and unable to access gvFiles_rowcommand below. Obviously I did something wrong.

            gvFiles.DataSource = files
            gvFiles.DataBind()

        End If
    End Sub







Private Sub gvFiles_RowCommand(sender As Object, e As GridViewRowEventArgs)
        Dim filePath As String = CType(sender, LinkButton).CommandArgument
        Response.ContentType = ContentType
        Response.AppendHeader("Content-Disposition", ("attachment; filename=" + Path.GetFileName(filePath)))
        Response.WriteFile(filePath)
        Response.End()
    End Sub





抱歉我的英文不好,希望有人可以帮助我。



sorry for my bad English and hope someone out there can help me.

推荐答案

e参数的类型应为GridViewCommandEventArgs



regs



ron O。
The e parameter should be of type GridViewCommandEventArgs

regs

ron O.


这篇关于如何在rowcommand事件上访问子gridview?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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