P
PatLaf
Hello to all, I converted a response I recieved in this newsgroup last week to vb.net but I can't convert this sub correctly. Can anyone help....the dgDeftects.ItemCommand never fires and I think it's because it's not wired up correctly.
Private Sub InitializeComponent()
dgDefects.ItemCommand += New System.Web.UI.WebControls.DataGridCommandEventHandler(AddressOf dgDefects_ItemCommand)
Me.Load += New System.EventHandler(Me.Page_Load)
End Sub 'InitializeComponent
Private Sub dgDefects_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)
Dim ovalue As Integer
ovalue = Integer.Parse(CType(e.Item.Controls(2), TableCell).Text)
If e.CommandName = "Increase" Then
CType(e.Item.Controls(2), TableCell).Text = (ovalue + 1).ToString()
Else
CType(e.Item.Controls(2), TableCell).Text = (ovalue - 1).ToString()
End If
End Sub 'dgDefects_ItemCommand
If Not Page.IsPostBack Then
Dim dt As New DataTable("MyTable")
dt.Columns.Add("IntValue", System.Type.GetType("System.Int16"))
dt.Columns.Add("StrValue", System.Type.GetType("System.String"))
Dim dr As DataRow = dt.NewRow()
dr(0) = 1
dt.Rows.Add(dr)
dr = dt.NewRow()
dr(0) = 2
dt.Rows.Add(dr)
dgDefects.DataSource = dt
dgDefects.DataBind()
End If
End Sub 'Page_Load
this is all the code that I have but the ide is complaining about the initialize component method.
Thanks in advance,
Patrick Laferriere
Private Sub InitializeComponent()
dgDefects.ItemCommand += New System.Web.UI.WebControls.DataGridCommandEventHandler(AddressOf dgDefects_ItemCommand)
Me.Load += New System.EventHandler(Me.Page_Load)
End Sub 'InitializeComponent
Private Sub dgDefects_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)
Dim ovalue As Integer
ovalue = Integer.Parse(CType(e.Item.Controls(2), TableCell).Text)
If e.CommandName = "Increase" Then
CType(e.Item.Controls(2), TableCell).Text = (ovalue + 1).ToString()
Else
CType(e.Item.Controls(2), TableCell).Text = (ovalue - 1).ToString()
End If
End Sub 'dgDefects_ItemCommand
If Not Page.IsPostBack Then
Dim dt As New DataTable("MyTable")
dt.Columns.Add("IntValue", System.Type.GetType("System.Int16"))
dt.Columns.Add("StrValue", System.Type.GetType("System.String"))
Dim dr As DataRow = dt.NewRow()
dr(0) = 1
dt.Rows.Add(dr)
dr = dt.NewRow()
dr(0) = 2
dt.Rows.Add(dr)
dgDefects.DataSource = dt
dgDefects.DataBind()
End If
End Sub 'Page_Load
this is all the code that I have but the ide is complaining about the initialize component method.
Thanks in advance,
Patrick Laferriere