Solved

datagrid itemCommand

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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

772 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