I am trying to retrieve data from a user clicking on a datagrid
button but I am getting the following error:
Method 'Public Sub dgNewUsersOnItemCommand(s As Object, e As System.Web.UI.WebControls.DataListCommandEventArgs )' does not have the same signature as delegate 'Delegate Sub DataGridCommandEventHandler(source As Object, e As System.Web.UI.WebControls.DataGridCommandEventArgs )'.
The Markup looks like this:
<%@ Page Language="
vb" AutoEventWireup="false" Codebehind="testdatagrid.aspx.
vb" Inherits="testsite.testdatagrid"%>
Head and body tags of course
<form id="Form1" method="post" runat="server">
<asp:DataGrid id="dgNewUsers"OnItemCommand="dgNewUsersOnItemComm and"
AutoGenerateColumns="False" BorderWidth="0" BorderStyle="None" runat="server">
<AlternatingItemStyle BackColor="LightSteelBlue"/>
<HeaderStyle Font-Bold="True" ForeColor="White" BackColor="LightSlateGray"/>
<Columns>
<asp:ButtonColumn Text="Approve Subscription"/>
<asp:BoundColumn DataField="userid" HeaderText="ID"></asp:BoundColumn>
<asp:BoundColumn DataField="username" HeaderText="User Name"></asp:BoundColumn>
<asp:BoundColumn DataField="firstname" HeaderText="First Name"></asp:BoundColumn>
<asp:BoundColumn DataField="middleinitial" HeaderText="Middle Initial"></asp:BoundColumn>
<asp:BoundColumn DataField="lastname" HeaderText="Last Name"></asp:BoundColumn>
<asp:BoundColumn DataField="levelidpicked" HeaderText="Level Picked"> </asp:BoundColumn>
<asp:BoundColumn DataField="lastlogin" HeaderText="Last Login Date"></asp:BoundColumn>
<asp:BoundColumn DataField="emailaddress" HeaderText="Email"></asp:BoundColumn>
</Columns>
</asp:DataGrid>
</form>
The code that is in the aspx.
vb file looks like this:
Imports System.Data.SqlClient
Public Class testdatagrid
Inherits System.Web.UI.Page
Dim con As New SqlConnection(
connection string)
Protected WithEvents dgNewUsers As System.Web.UI.WebControls.DataGrid
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
getnewusers()
End If
End Sub
Sub getnewusers()
Dim cmd As New SqlCommand("exec sp_get_users 1", con)
Dim da As New SqlDataAdapter
Dim ds As New DataSet
Try
If con.State = ConnectionState.Open Then
con.Close()
End If
da.SelectCommand = cmd
da.Fill(ds)
con.Close()
Catch ex As Exception
Throw ex
End Try
dgNewUsers.DataSource = ds
dgNewUsers.DataBind()
End Sub
Sub dgNewUsersOnItemCommand(ByVal s As Object, ByVal e As DataListCommandEventArgs)
Response.Write("Helpme")
End Sub
End Class
When I put the sub dgNewUsersOnItemCommand on the markup page between the
<script language=
vb runat=server></script> tags it works like a champ. But I cannot get this to run in the .
vb file. I know I am missing something obvious.
TIA,
Cowa