Solved

datagrid itemCommand

Posted on 2004-08-23
3
748 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 100 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

820 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