Solved

datagrid itemCommand

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Unable to get blue colour in background of using HTML 6 56
asp.net mvc5 3 38
DLL in ASP.NET 20 44
Hidden Field Value 10 34
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
This video discusses moving either the default database or any database to a new volume.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now