我知道这是一个经常被问到的问题,但是我找不到答案。我希望你能帮助我。我尝试将imagebutton控件绑定到一个网格视图中。我想要处理单击按钮所在行的数据
我的aspx文件看起来像
<asp:ImageButton ID="Button1"
runat="server"
ImageUrl="~/Images/deny.png"
Height="45" Width="45"
CommandName="SelectComment"
CommandArgument='<%# Container.DataItemIndex %>' />vb文件看起来像这样。
Protected Sub KontaktAnfragen_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles KontaktAnfragen.RowCommand
Dim rowIndex As Integer
Dim commentHiddenField As HiddenField
If e.CommandName = "SelectComment" Then
rowIndex = Integer.Parse(e.CommandName.ToString)问题是页面不能处理点击。it do nothing.it甚至不会跳到RowCommand函数中
诚挚的问候
发布于 2010-10-14 16:35:11
您需要将"KontaktAnfragen_RowCommand“分配给图像按钮所在的Gridview的OnRowCommand事件。
OnRowCommand="KontaktAnfragen_RowCommand"我刚刚注意到,在上面的代码中,您不应该使用CommandArgument值而不是rowIndex的CommandName值
此外,我不确定是否需要使用ToString,但如果需要,请使用ToString()而不是ToString,因为它是一个方法调用。
类似这样的内容(包括if语句的格式,等等):
if (e.CommandName == "SelectComment") Then
rowIndex = Integer.Parse(e.CommandArgument)https://stackoverflow.com/questions/3928531
复制相似问题