473,382 Members | 1,329 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

datagrid_ItemCommand problem

Hi there

I am using a button column>SELECT and a datagrid.Item_Command to take a
value from the datagrid (in this case a customer account number) - store that
value in to a session variable and transfer to another page which picks up
the session variable and uses it to display information for that particular
customer:

Public Sub CustomerSearchGrid_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
CustomerSearchGrid.ItemCommand
If e.Item.ItemIndex >= 0 Then

Dim Ownercell1 As TableCell = CType(e.Item.Controls(1), TableCell)

UserSession.Current.CurrentAccNumber = Ownercell1.Text & "%"
Server.Transfer("/webapplication/CustomerBasicInfo.aspx")
End If
End Sub

This works great on the first click. However, if I then click on BACK and
choose another customer by clicking SELECT on the datagrid the above event
does not fire - anyone know what I am doing wrong please ???

Thanks very much for your help
Nov 19 '05 #1
3 2332
I know this sounds strange...but humor me....
Change your button to a Link Button and see if that fixes it
"Stuart" <St****@discussions.microsoft.com> wrote in message
news:F5**********************************@microsof t.com...
Hi there

I am using a button column>SELECT and a datagrid.Item_Command to take a
value from the datagrid (in this case a customer account number) - store that value in to a session variable and transfer to another page which picks up
the session variable and uses it to display information for that particular customer:

Public Sub CustomerSearchGrid_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
CustomerSearchGrid.ItemCommand
If e.Item.ItemIndex >= 0 Then

Dim Ownercell1 As TableCell = CType(e.Item.Controls(1), TableCell)
UserSession.Current.CurrentAccNumber = Ownercell1.Text & "%"
Server.Transfer("/webapplication/CustomerBasicInfo.aspx")
End If
End Sub

This works great on the first click. However, if I then click on BACK and
choose another customer by clicking SELECT on the datagrid the above event
does not fire - anyone know what I am doing wrong please ???

Thanks very much for your help

Nov 19 '05 #2
Hi David (by the way this relates to the session variables HELP!! problem
that you have already helped me with....)

Do you mean a hyperlink ? If so - how do I store the session variable ?
(recognise the code ;-) )

If you mean a SELECT column with button type: set to linkbutton - it already
is I'm afraid... in fact if I change it to pushbutton the event doesn't seem
to fire in the first place...

I have been messing around with using _SelectedIndexChanged instead as I am
starting to assume that when you click BACK to a page with a grid from a page
that is linked by the _ItemCommand event from that same grid originally, for
whatever reason, _ItemCommand simply doesn't want to play.... However, I
can't work out how to get the value from the datagrid in to Session when
using this event as Ctype(e.item.controls(1), TableCell) is thoroughly not
availale in the same way as under _ItemCommand event - perhaps you have some
thoughts on this ???

I reason that _SelectedIndexChanged may be more accessible in my particular
environment ? (there is much scope for me being wrong on this subject I'm
afraid - so please ignore and supply any other ideas you may have if that is
obvious....)

Thanks for all your help David

"David Jessee" wrote:
I know this sounds strange...but humor me....
Change your button to a Link Button and see if that fixes it
"Stuart" <St****@discussions.microsoft.com> wrote in message
news:F5**********************************@microsof t.com...
Hi there

I am using a button column>SELECT and a datagrid.Item_Command to take a
value from the datagrid (in this case a customer account number) - store

that
value in to a session variable and transfer to another page which picks up
the session variable and uses it to display information for that

particular
customer:

Public Sub CustomerSearchGrid_ItemCommand(ByVal source As Object, ByVal e

As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
CustomerSearchGrid.ItemCommand
If e.Item.ItemIndex >= 0 Then

Dim Ownercell1 As TableCell = CType(e.Item.Controls(1),

TableCell)

UserSession.Current.CurrentAccNumber = Ownercell1.Text & "%"
Server.Transfer("/webapplication/CustomerBasicInfo.aspx")
End If
End Sub

This works great on the first click. However, if I then click on BACK and
choose another customer by clicking SELECT on the datagrid the above event
does not fire - anyone know what I am doing wrong please ???

Thanks very much for your help


Nov 19 '05 #3
Well, as far as getting a value from a cell, let's say that the field you're
looking for is called "IdField". Set your datagrid's DataKeyField to
"IdField" that way when you're inside of the handler, refer to
MyGrid.DataKeys(e.Item.Itemindex).

as far as SelectedIndexChanged.....

SelectedIndexChanged, SelectCommand, DeleteCommand, UpdateCommand and all of
the rest of those "command" events are just overloads of the ItemCommand
Event. Feel Free to do what you need to, but I only ude the ItemCommand
because that way I don't end up with 20 event handlers.
"Stuart" <St****@discussions.microsoft.com> wrote in message
news:18**********************************@microsof t.com...
Hi David (by the way this relates to the session variables HELP!! problem
that you have already helped me with....)

Do you mean a hyperlink ? If so - how do I store the session variable ?
(recognise the code ;-) )

If you mean a SELECT column with button type: set to linkbutton - it already is I'm afraid... in fact if I change it to pushbutton the event doesn't seem to fire in the first place...

I have been messing around with using _SelectedIndexChanged instead as I am starting to assume that when you click BACK to a page with a grid from a page that is linked by the _ItemCommand event from that same grid originally, for whatever reason, _ItemCommand simply doesn't want to play.... However, I
can't work out how to get the value from the datagrid in to Session when
using this event as Ctype(e.item.controls(1), TableCell) is thoroughly not
availale in the same way as under _ItemCommand event - perhaps you have some thoughts on this ???

I reason that _SelectedIndexChanged may be more accessible in my particular environment ? (there is much scope for me being wrong on this subject I'm
afraid - so please ignore and supply any other ideas you may have if that is obvious....)

Thanks for all your help David

"David Jessee" wrote:
I know this sounds strange...but humor me....
Change your button to a Link Button and see if that fixes it
"Stuart" <St****@discussions.microsoft.com> wrote in message
news:F5**********************************@microsof t.com...
Hi there

I am using a button column>SELECT and a datagrid.Item_Command to take a value from the datagrid (in this case a customer account number) - store
that
value in to a session variable and transfer to another page which
picks up the session variable and uses it to display information for that

particular
customer:

Public Sub CustomerSearchGrid_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
CustomerSearchGrid.ItemCommand
If e.Item.ItemIndex >= 0 Then

Dim Ownercell1 As TableCell = CType(e.Item.Controls(1),

TableCell)

UserSession.Current.CurrentAccNumber = Ownercell1.Text &

"%" Server.Transfer("/webapplication/CustomerBasicInfo.aspx")
End If
End Sub

This works great on the first click. However, if I then click on BACK and choose another customer by clicking SELECT on the datagrid the above event does not fire - anyone know what I am doing wrong please ???

Thanks very much for your help


Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Bruce Davis | last post by:
I'm having a problem on windows (both 2000 and XP) with a multi-threaded tkinter gui application. The problem appears to be a deadlock condition when a child thread pops up a Pmw dialog window in...
11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
0
by: Refky Wahib | last post by:
Hi I need Technical Support I finished a Great project using .Net and SQL Server and .Net Mobile Control My Business case is to implement this Program to accept about 1 Million concurrent...
9
by: Sudesh Sawant | last post by:
Hello, We have an application which communicates using remoting. There is a server which is a Windows Service. The server exposes an object which is a singleton. The client is a Web Application...
117
by: Peter Olcott | last post by:
www.halting-problem.com
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.