By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,950 Members | 1,019 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,950 IT Pros & Developers. It's quick & easy.

datagrid OnCancelCommand

P: n/a
My datagrid OnCancelCommand event is not firing.

HTML
OnCancelCommand="AdminGrid_Cancel"

'Code Behind
Sub AdminGrid_Cancel(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
AdminGrid.EditItemIndex = -1
BindData()
End Sub

Does anyone have any clues as to why it is not firing?
Thanks,
Brent
Nov 18 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Brent Burkart wrote:
My datagrid OnCancelCommand event is not firing.

HTML
OnCancelCommand="AdminGrid_Cancel"

'Code Behind
Sub AdminGrid_Cancel(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
AdminGrid.EditItemIndex = -1
BindData()
End Sub

Does anyone have any clues as to why it is not firing?
Thanks,
Brent


Brent,

If you are using VS.Net IDE, i had quite the same experience. Try
investigating by looking at the actual declaration of the hook-events
delegation. For some reason, sometimes, the IDE is taking out this
delegation.

hth,
Jonel

Nov 18 '05 #2

P: n/a
Thank Jonel,

I guess I am not sure what you are telling me.

I did add the handler keyword such as the following:

Sub AdminGrid_Cancel(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs) Handles AdminGrid.CancelCommand

This didn't seem to do anything.

I am new to .NET. I am not sure what you mean by delegation.

Thanks for your patience.

Brent

"Jonel Rienton" <csharp@nospam_.core.com> wrote in message
news:3FB92857.9020207@nospam_.core.com...
Brent Burkart wrote:
My datagrid OnCancelCommand event is not firing.

HTML
OnCancelCommand="AdminGrid_Cancel"

'Code Behind
Sub AdminGrid_Cancel(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
AdminGrid.EditItemIndex = -1
BindData()
End Sub

Does anyone have any clues as to why it is not firing?
Thanks,
Brent


Brent,

If you are using VS.Net IDE, i had quite the same experience. Try
investigating by looking at the actual declaration of the hook-events
delegation. For some reason, sometimes, the IDE is taking out this
delegation.

hth,
Jonel

Nov 18 '05 #3

P: n/a
Brent,

1) are you using VS.Net? or are you using another IDE?
2) i'm more of a C# developer, so i'll try to give it a shot here

aren't you, in VB.Net, supposed to declare an event-hook handler
somewhere(Page_Load,Page_Init) like:

AddHandler AdminGrid.CancelCommand, AddressOf AdminGrid_Cancel

let me know how it goes,

Jonel
Brent Burkart wrote:
Thank Jonel,

I guess I am not sure what you are telling me.

I did add the handler keyword such as the following:

Sub AdminGrid_Cancel(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs) Handles AdminGrid.CancelCommand

This didn't seem to do anything.

I am new to .NET. I am not sure what you mean by delegation.

Thanks for your patience.

Brent

"Jonel Rienton" <csharp@nospam_.core.com> wrote in message
news:3FB92857.9020207@nospam_.core.com...
Brent Burkart wrote:

My datagrid OnCancelCommand event is not firing.

HTML
OnCancelCommand="AdminGrid_Cancel"

'Code Behind
Sub AdminGrid_Cancel(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
AdminGrid.EditItemIndex = -1
BindData()
End Sub

Does anyone have any clues as to why it is not firing?
Thanks,
Brent


Brent,

If you are using VS.Net IDE, i had quite the same experience. Try
investigating by looking at the actual declaration of the hook-events
delegation. For some reason, sometimes, the IDE is taking out this
delegation.

hth,
Jonel


Nov 18 '05 #4

P: n/a
Thanks Jonel,

I am using VS.NET and you were correct in adding the AddHandler statement.
However, the event is still not firing. I appreciate your help because I am
at a loss.

Thanks,
Brent
"Jonel Rienton" <csharp@nospam_.core.com> wrote in message
news:3FB940F6.2060004@nospam_.core.com...
Brent,

1) are you using VS.Net? or are you using another IDE?
2) i'm more of a C# developer, so i'll try to give it a shot here

aren't you, in VB.Net, supposed to declare an event-hook handler
somewhere(Page_Load,Page_Init) like:

AddHandler AdminGrid.CancelCommand, AddressOf AdminGrid_Cancel

let me know how it goes,

Jonel
Brent Burkart wrote:
Thank Jonel,

I guess I am not sure what you are telling me.

I did add the handler keyword such as the following:

Sub AdminGrid_Cancel(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs) Handles AdminGrid.CancelCommand

This didn't seem to do anything.

I am new to .NET. I am not sure what you mean by delegation.

Thanks for your patience.

Brent

"Jonel Rienton" <csharp@nospam_.core.com> wrote in message
news:3FB92857.9020207@nospam_.core.com...
Brent Burkart wrote:
My datagrid OnCancelCommand event is not firing.

HTML
OnCancelCommand="AdminGrid_Cancel"

'Code Behind
Sub AdminGrid_Cancel(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
AdminGrid.EditItemIndex = -1
BindData()
End Sub

Does anyone have any clues as to why it is not firing?
Thanks,
Brent

Brent,

If you are using VS.Net IDE, i had quite the same experience. Try
investigating by looking at the actual declaration of the hook-events
delegation. For some reason, sometimes, the IDE is taking out this
delegation.

hth,
Jonel



Nov 18 '05 #5

P: n/a
Brent,

let's take this one step at a time, insert a Debug.WriteLine statement
in your event handler like:

'Code Behind
Sub AdminGrid_Cancel(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
System.Diagnostics.Debug.WriteLine("admingrid_canc el called")
AdminGrid.EditItemIndex = -1
BindData()
End Sub

then run your webapp in debug mode and look at your debug window as you
test your application.

Brent Burkart wrote:
Thanks Jonel,

I am using VS.NET and you were correct in adding the AddHandler statement.
However, the event is still not firing. I appreciate your help because I am
at a loss.

Thanks,
Brent
"Jonel Rienton" <csharp@nospam_.core.com> wrote in message
news:3FB940F6.2060004@nospam_.core.com...
Brent,

1) are you using VS.Net? or are you using another IDE?
2) i'm more of a C# developer, so i'll try to give it a shot here

aren't you, in VB.Net, supposed to declare an event-hook handler
somewhere(Page_Load,Page_Init) like:

AddHandler AdminGrid.CancelCommand, AddressOf AdminGrid_Cancel

let me know how it goes,

Jonel
Brent Burkart wrote:

Thank Jonel,

I guess I am not sure what you are telling me.

I did add the handler keyword such as the following:

Sub AdminGrid_Cancel(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs) Handles AdminGrid.CancelCommand

This didn't seem to do anything.

I am new to .NET. I am not sure what you mean by delegation.

Thanks for your patience.

Brent

"Jonel Rienton" <csharp@nospam_.core.com> wrote in message
news:3FB92857.9020207@nospam_.core.com...
Brent Burkart wrote:

>My datagrid OnCancelCommand event is not firing.
>
>HTML
>OnCancelCommand="AdminGrid_Cancel"
>
>'Code Behind
>Sub AdminGrid_Cancel(ByVal sender As Object, ByVal e As
>DataGridCommandEventArgs)
> AdminGrid.EditItemIndex = -1
> BindData()
>End Sub
>
>Does anyone have any clues as to why it is not firing?
>Thanks,
>Brent
>
>

Brent,

If you are using VS.Net IDE, i had quite the same experience. Try
investigating by looking at the actual declaration of the hook-events
delegation. For some reason, sometimes, the IDE is taking out this
delegation.

hth,
Jonel



Nov 18 '05 #6

P: n/a
Thanks Jonel,

I really appreciate your help. I do set a breakpoint and it never hits my
events. I also put the debug statement in and nothing.

I should tell you my AdminGrid_UpdateCommand will not fire either. I don't
know if that sheds any light on anything or not.

Thanks,
Brent
"Jonel Rienton" <csharp@nospam_.core.com> wrote in message
news:3FB94C58.4040503@nospam_.core.com...
Brent,

let's take this one step at a time, insert a Debug.WriteLine statement
in your event handler like:

'Code Behind
Sub AdminGrid_Cancel(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
System.Diagnostics.Debug.WriteLine("admingrid_canc el called")
AdminGrid.EditItemIndex = -1
BindData()
End Sub

then run your webapp in debug mode and look at your debug window as you
test your application.

Brent Burkart wrote:
Thanks Jonel,

I am using VS.NET and you were correct in adding the AddHandler statement. However, the event is still not firing. I appreciate your help because I am at a loss.

Thanks,
Brent
"Jonel Rienton" <csharp@nospam_.core.com> wrote in message
news:3FB940F6.2060004@nospam_.core.com...
Brent,

1) are you using VS.Net? or are you using another IDE?
2) i'm more of a C# developer, so i'll try to give it a shot here

aren't you, in VB.Net, supposed to declare an event-hook handler
somewhere(Page_Load,Page_Init) like:

AddHandler AdminGrid.CancelCommand, AddressOf AdminGrid_Cancel

let me know how it goes,

Jonel
Brent Burkart wrote:
Thank Jonel,

I guess I am not sure what you are telling me.

I did add the handler keyword such as the following:

Sub AdminGrid_Cancel(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs) Handles AdminGrid.CancelCommand

This didn't seem to do anything.

I am new to .NET. I am not sure what you mean by delegation.

Thanks for your patience.

Brent

"Jonel Rienton" <csharp@nospam_.core.com> wrote in message
news:3FB92857.9020207@nospam_.core.com...
>Brent Burkart wrote:
>
>
>
>>My datagrid OnCancelCommand event is not firing.
>>
>>HTML
>>OnCancelCommand="AdminGrid_Cancel"
>>
>>'Code Behind
>>Sub AdminGrid_Cancel(ByVal sender As Object, ByVal e As
>>DataGridCommandEventArgs)
>> AdminGrid.EditItemIndex = -1
>> BindData()
>>End Sub
>>
>>Does anyone have any clues as to why it is not firing?
>>Thanks,
>>Brent
>>
>>
>
>Brent,
>
>If you are using VS.Net IDE, i had quite the same experience. Try
>investigating by looking at the actual declaration of the hook-events
>delegation. For some reason, sometimes, the IDE is taking out this
>delegation.
>
>hth,
>Jonel
>


Nov 18 '05 #7

P: n/a
Brent,

are you hooking up the events manually or are you letting VS.Net IDE do
it for you? if the latter, check to make sure that the IDE is indeed
hooking up the events and the eventhandlers.

Jonel

[1] you can send me a snippet of your code offline if you'd like so i
can take a look at it.

Brent Burkart wrote:
Thanks Jonel,

I really appreciate your help. I do set a breakpoint and it never hits my
events. I also put the debug statement in and nothing.

I should tell you my AdminGrid_UpdateCommand will not fire either. I don't
know if that sheds any light on anything or not.

Thanks,
Brent
"Jonel Rienton" <csharp@nospam_.core.com> wrote in message
news:3FB94C58.4040503@nospam_.core.com...
Brent,

let's take this one step at a time, insert a Debug.WriteLine statement
in your event handler like:

'Code Behind
Sub AdminGrid_Cancel(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
System.Diagnostics.Debug.WriteLine("admingrid_canc el called")
AdminGrid.EditItemIndex = -1
BindData()
End Sub

then run your webapp in debug mode and look at your debug window as you
test your application.

Brent Burkart wrote:

Thanks Jonel,

I am using VS.NET and you were correct in adding the AddHandler
statement.
However, the event is still not firing. I appreciate your help because
I am
at a loss.

Thanks,
Brent
"Jonel Rienton" <csharp@nospam_.core.com> wrote in message
news:3FB940F6.2060004@nospam_.core.com...
Brent,

1) are you using VS.Net? or are you using another IDE?
2) i'm more of a C# developer, so i'll try to give it a shot here

aren't you, in VB.Net, supposed to declare an event-hook handler
somewhere(Page_Load,Page_Init) like:

AddHandler AdminGrid.CancelCommand, AddressOf AdminGrid_Cancel

let me know how it goes,

Jonel
Brent Burkart wrote:

>Thank Jonel,
>
>I guess I am not sure what you are telling me.
>
>I did add the handler keyword such as the following:
>
>Sub AdminGrid_Cancel(ByVal sender As Object, ByVal e As
>DataGridCommandEventArgs) Handles AdminGrid.CancelCommand
>
>This didn't seem to do anything.
>
>I am new to .NET. I am not sure what you mean by delegation.
>
>Thanks for your patience.
>
>Brent
>
>"Jonel Rienton" <csharp@nospam_.core.com> wrote in message
>news:3FB92857.9020207@nospam_.core.com...
>
>
>
>>Brent Burkart wrote:
>>
>>
>>
>>
>>>My datagrid OnCancelCommand event is not firing.
>>>
>>>HTML
>>>OnCancelCommand="AdminGrid_Cancel"
>>>
>>>'Code Behind
>>>Sub AdminGrid_Cancel(ByVal sender As Object, ByVal e As
>>>DataGridCommandEventArgs)
>>> AdminGrid.EditItemIndex = -1
>>> BindData()
>>>End Sub
>>>
>>>Does anyone have any clues as to why it is not firing?
>>>Thanks,
>>>Brent
>>>
>>>
>>
>>Brent,
>>
>>If you are using VS.Net IDE, i had quite the same experience. Try
>>investigating by looking at the actual declaration of the hook-events
>>delegation. For some reason, sometimes, the IDE is taking out this
>>delegation.
>>
>>hth,
>>Jonel
>>
>
>
>



Nov 18 '05 #8

P: n/a
Jonel,

Here is the code. Thanks so much for your help

HTML
<form runat="server">

<asp:DataGrid runat="server" id="AdminGrid" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" BackColor="White" CellPadding="3" Width="742px" Height="231px" DataKeyField="ProductID" AutoGenerateColumns="False" OnEditCommand="AdminGrid_EditCommand" OnCancelCommand="AdminGrid_CancelCommand" OnUpdateCommand="AdminGrid_UpdateCommand">

<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#669999"></SelectedItemStyle>

<ItemStyle ForeColor="#000066"></ItemStyle>

<HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#006699"></HeaderStyle>

<FooterStyle ForeColor="#000066" BackColor="White"></FooterStyle>

<Columns>

<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>

<asp:BoundColumn DataField="ModelName" HeaderText="Product Name"></asp:BoundColumn>

<asp:BoundColumn DataField="ModelNumber" HeaderText="Product Number"></asp:BoundColumn>

<asp:BoundColumn DataField="ProductImage" HeaderText="Product Image"></asp:BoundColumn>

<asp:BoundColumn DataField="itemcount" HeaderText="Item Count">

<HeaderStyle Width="35px"></HeaderStyle>

</asp:BoundColumn>

<asp:HyperLinkColumn Text="Level Setup" DataNavigateUrlField="ProductID" NavigateUrl="AdminPrice.aspx?id={0}">

<HeaderStyle Width="35px"></HeaderStyle>

</asp:HyperLinkColumn>

<asp:BoundColumn DataField="description" HeaderText="Description">

<HeaderStyle Width="150px"></HeaderStyle>

</asp:BoundColumn>

</Columns>

<PagerStyle HorizontalAlign="Left" ForeColor="#000066" BackColor="White" Mode="NumericPages"></PagerStyle>

</asp:DataGrid></form>

'Code Behind
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

If Not Page.IsPostBack Then

BindData()

End If

AddHandler AdminGrid.CancelCommand, AddressOf AdminGrid_CancelCommand

AddHandler AdminGrid.UpdateCommand, AddressOf AdminGrid_UpdateCommand

End Sub

Sub BindData()

Dim CategoryID As Integer = CInt(Request.Params("categoryid"))



' Obtain Product Details

Dim products As ProductsDB = New ProductsDB()





' Databind Gridcontrol with Shopping Cart Items

AdminGrid.DataSource = products.GetCompleteProductDetails(CategoryID)

AdminGrid.DataBind()





End Sub

Private Sub AdminGrid_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AdminGrid.SelectedIndexChanged



End Sub

Sub AdminGrid_EditCommand(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)

AdminGrid.EditItemIndex = e.Item.ItemIndex

BindData()

End Sub

Sub AdminGrid_CancelCommand(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles AdminGrid.CancelCommand

System.Diagnostics.Debug.WriteLine("admingrid_canc el called")

AdminGrid.EditItemIndex = -1

BindData()

End Sub



Sub AdminGrid_UpdateCommand(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles AdminGrid.UpdateCommand



Dim product As ASPNET.StarterKit.Commerce.ProductsDB = New ASPNET.StarterKit.Commerce.ProductsDB()

'Iterate through all rows within datagrid



Dim i As Integer

For i = 0 To AdminGrid.Items.Count - 1

Dim ProductIdTxt As TextBox = CType(AdminGrid.Items(i).FindControl("productid"), TextBox)

Dim ModelNumberTxt As TextBox = CType(AdminGrid.Items(i).FindControl("ModelNumber" ), TextBox)

Dim ModelNameTxt As TextBox = CType(AdminGrid.Items(i).FindControl("ModelName"), TextBox)

Dim ProductImageTxt As TextBox = CType(AdminGrid.Items(i).FindControl("ProductImage "), TextBox)

Dim DescriptionTxt As TextBox = CType(AdminGrid.Items(i).FindControl("Description" ), TextBox)

Dim ItemCountTxt As TextBox = CType(AdminGrid.Items(i).FindControl("ItemCount"), TextBox)

Dim ProductId As Integer

Dim ModelNumber As String

Dim ModelName As String

Dim ProductImage As String

Dim Description As String

Dim ItemCount As Integer



product.UpdateDetails(ProductId, ModelNumber, ModelName, ProductImage, Description, ItemCount)



AdminGrid.EditItemIndex = -1

BindData()

Next

End Sub

"Jonel Rienton" <csharp@nospam_.core.com> wrote in message news:3FB98ECA.1070309@nospam_.core.com...
Brent,

are you hooking up the events manually or are you letting VS.Net IDE do
it for you? if the latter, check to make sure that the IDE is indeed
hooking up the events and the eventhandlers.

Jonel

[1] you can send me a snippet of your code offline if you'd like so i
can take a look at it.

Brent Burkart wrote:
Thanks Jonel,

I really appreciate your help. I do set a breakpoint and it never hits my
events. I also put the debug statement in and nothing.

I should tell you my AdminGrid_UpdateCommand will not fire either. I don't
know if that sheds any light on anything or not.

Thanks,
Brent
"Jonel Rienton" <csharp@nospam_.core.com> wrote in message
news:3FB94C58.4040503@nospam_.core.com...
Brent,

let's take this one step at a time, insert a Debug.WriteLine statement
in your event handler like:

'Code Behind
Sub AdminGrid_Cancel(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
System.Diagnostics.Debug.WriteLine("admingrid_canc el called")
AdminGrid.EditItemIndex = -1
BindData()
End Sub

then run your webapp in debug mode and look at your debug window as you
test your application.

Brent Burkart wrote:
Thanks Jonel,

I am using VS.NET and you were correct in adding the AddHandler


statement.
However, the event is still not firing. I appreciate your help because


I am
at a loss.

Thanks,
Brent
"Jonel Rienton" <csharp@nospam_.core.com> wrote in message
news:3FB940F6.2060004@nospam_.core.com...
>Brent,
>
>1) are you using VS.Net? or are you using another IDE?
>2) i'm more of a C# developer, so i'll try to give it a shot here
>
> aren't you, in VB.Net, supposed to declare an event-hook handler
>somewhere(Page_Load,Page_Init) like:
>
>AddHandler AdminGrid.CancelCommand, AddressOf AdminGrid_Cancel
>
>let me know how it goes,
>
>Jonel
>
>
>Brent Burkart wrote:
>
>
>
>>Thank Jonel,
>>
>>I guess I am not sure what you are telling me.
>>
>>I did add the handler keyword such as the following:
>>
>>Sub AdminGrid_Cancel(ByVal sender As Object, ByVal e As
>>DataGridCommandEventArgs) Handles AdminGrid.CancelCommand
>>
>>This didn't seem to do anything.
>>
>>I am new to .NET. I am not sure what you mean by delegation.
>>
>>Thanks for your patience.
>>
>>Brent
>>
>>"Jonel Rienton" <csharp@nospam_.core.com> wrote in message
>>news:3FB92857.9020207@nospam_.core.com...
>>
>>
>>
>>>Brent Burkart wrote:
>>>
>>>
>>>
>>>
>>>>My datagrid OnCancelCommand event is not firing.
>>>>
>>>>HTML
>>>>OnCancelCommand="AdminGrid_Cancel"
>>>>
>>>>'Code Behind
>>>>Sub AdminGrid_Cancel(ByVal sender As Object, ByVal e As
>>>>DataGridCommandEventArgs)
>>>> AdminGrid.EditItemIndex = -1
>>>> BindData()
>>>>End Sub
>>>>
>>>>Does anyone have any clues as to why it is not firing?
>>>>Thanks,
>>>>Brent
>>>>
>>>>
>>>
>>>Brent,
>>>
>>>If you are using VS.Net IDE, i had quite the same experience. Try
>>>investigating by looking at the actual declaration of the hook-events
>>>delegation. For some reason, sometimes, the IDE is taking out this
>>>delegation.
>>>
>>>hth,
>>>Jonel
>>>
>>
>>
>>



Nov 18 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.