Grindview with imagebutton and rowcommand
i know this a frequently asked question, but i cant find the solution. I hope u can help me. i try ti bind开发者_JS百科 imagebutton controls into a gridview. i want to handle the data for the row where the button was clicked
my aspx file looks like
<asp:ImageButton ID="Button1"
runat="server"
ImageUrl="~/Images/deny.png"
Height="45" Width="45"
CommandName="SelectComment"
CommandArgument='<%# Container.DataItemIndex %>' />
and the vb file looks like
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)
The problem ist that the page does not handle the click. it do nothing.it even does not jump in the RowCommand function
Best regards
If I understand your code correctly, you need to add OnClick="KontaktAnfragen_RowCommand" to the ImageButton.
You need to assign the "KontaktAnfragen_RowCommand" to the Gridview's OnRowCommand event the image button is in.
OnRowCommand="KontaktAnfragen_RowCommand"
I just noticed, in your aboove code, should you not be using the CommandArgument value instead of the CommandName value for the rowIndex?
Also I'm not sure you need to use ToString but if you do, use ToString() instead of ToString as it is a method call.
Something like this (included formatting of if statement, etc..)?:
if (e.CommandName == "SelectComment") Then
rowIndex = Integer.Parse(e.CommandArgument)
加载中,请稍侯......
精彩评论