如何在gridview delete中的命令参数中传递第二个参数 [英] How to pass second parameter in the command argument in gridview delete
本文介绍了如何在gridview delete中的命令参数中传递第二个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有网格,我需要传递两个参数.
目前,我正在传递一个参数..?
如何在命令参数中传递第二个参数.
请参见下面的代码.
---------------
ASPX页面
---------
Hi,
I have grid and i need to pass two parameters.
Currently i am passing one parameter..?
How to pass second parameter in the command argument.
See code below.
---------------
ASPX Page
---------
<asp:TemplateField HeaderText="Delete" ItemStyle-HorizontalAlign="Center">
<itemtemplate>
<asp:ImageButton ID="btnDelete" runat="server" CommandName="Delete" Height="20"
ImageUrl="~/images/DeleteImage.png" OnClientClick="return confirm(''Are you sure you want to delete this PR Number.?'');"
CommandArgument=''<%# Eval("ENo") %>''
Width="20" />
</itemtemplate>
<itemstyle horizontalalign="Center" width="2%" />
ASPX.VB代码
------------
ASPX.VB Code
------------
Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
'Dim DesigCode As String = GridView1.Rows(e.RowIndex).Cells(1).Text
If e.CommandName = "Delete" Then
'get the EmpNumber of the clicked row
Dim ENo As Integer = Convert.ToInt32(e.CommandArgument)
'Delete the record
If ENo.ToString IsNot Nothing Then
Conn.Open()
Qry = ""
Qry = "DELETE FROM PMC WHERE ENo='" & ENo & "'"
Cmd.Connection = Conn
Cmd.CommandText = Qry
'Cmd.ExecuteNonQuery()
Conn.Close()
End If
FillGrid()
End If
End Sub
推荐答案
您需要将它们构建为一个值,例如具有分隔符或XML的字符串.
You would need to build them in to one value, such as a string that has a seperator, or is XML.
试试这个
try this
CommandArgument=''<%#Eval("ENo") + ","+Eval("EValue") %>''
Protected Sub GridView1_RowCommand(sender As Object, e As GridViewCommandEventArgs)
If e.CommandName = "Test" Then
Dim commandArgs As String() = e.CommandArgument.ToString().Split(New Char() {","C})
dim id as integer = commandArgs(0)
dim value as string = commandArgs(1)
End If
End Sub
这篇关于如何在gridview delete中的命令参数中传递第二个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文