Solved

datagrid itemCommand

Posted on 2004-08-23
3
751 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
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 …
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

707 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