?
Solved

datagrid itemCommand

Posted on 2004-08-23
3
Medium Priority
?
764 Views
Last Modified: 2008-02-01
Hello, I m trying to read a command name inside _ItemCommand  and call functions on different command names
this is what i'm trying to test here

 Private Sub DepartmentGrid_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DepartmentGrid.ItemCommand

if e.commandName.toString = "delete"
response.redirect("bluh.aspx?delete=true")
end if

End Sub

is this the right way to test commandName cuz for some reasons it will not get into if statement

thank you
0
Comment
Question by:rod80
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
shovavnik earned 400 total points
ID: 11875065
First of all, you don't the .ToString() call because e.CommandName is already a string.

Second, Are you sure the method is being called?
That is, the following conditions need to be met for this function to be called:
1. The ItemCommand event handler is bound to the ItemCommand even of the datagrid.  You should have in your code somewhere a DepartmentGrid.ItemCommand += DepartmentGrid_ItemCommand, or in your aspx a similar attribute on your datagrid.
2. You need to have a button or something whose CommandName is set to "delete".  This is case-sensitive, unless you check: if e.CommandName.ToLower() = "delete"
3. That button needs to be inside the datagrid (in the a TemplateColumn for example).

In general, though, your logic should work.  It's probably just a matter of binding the right handler to the right event.

(Side note: you might want to consider using Microsoft's case for your functions for better readability and cross-language support.)
0
 

Author Comment

by:rod80
ID: 11876882
Oh Boy i can't believe i wasted 2 days just because of the case-sensitive thingy
thx
0
 
LVL 8

Expert Comment

by:shovavnik
ID: 11879251
It happens to the best of us :)

You're welcome.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Screencast - Getting to Know the Pipeline
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question