473,395 Members | 2,467 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,395 software developers and data experts.

ASP - Gridview


I am trying to findout which column the user clicked on in a gridview.

column 0 = CommandField ( view)
column 1 = CommandFiled ( edit)

When the event grdTemp_SelectedIndexChanged
occurs on the server I want to know which column was selected
eg do somthing when view pressed do somthing else when edit pressed.

Thanks in advance
--
Life in the sun
May 31 '06 #1
4 5294
Hi,

Thank you for your post!

Based on my understanding, the SelectedIndexChanged event is occurred when
a row's Select button is clicked, it has nothing to do with which column is
clicked or selected.

You can set property AutoGenerateSelectButton="true" and
AutoGenerateEditButton="true" to generate two columns of "Select" and
"Edit". When a user clicks the "Select" link to select a row, the event
SelectedIndexChanged is triggered. When a user clicks the "Edit" link to
edit a row, the event RowEditing is triggered.

Hope this helps. If anything is unclear, please feel free to post here.

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

May 31 '06 #2
Hello Walter,
I suppose what I am saying is if you have many commandField Columns in a
gridview. When you click on on of the columns . How on the server can you
tell which command button was pressed ?
Is there another event raised by the commandfields other than
"SelectedIndexChanged "

ps.
I would rather not use AutoGenerateSelectButton="true" and
AutoGenerateEditButton="true". I want to change the look of these two
columns to
contain a image rather than words. Like you can do with a command button

Thanks



--
Life in the sun
"Walter Wang [MSFT]" wrote:
Hi,

Thank you for your post!

Based on my understanding, the SelectedIndexChanged event is occurred when
a row's Select button is clicked, it has nothing to do with which column is
clicked or selected.

You can set property AutoGenerateSelectButton="true" and
AutoGenerateEditButton="true" to generate two columns of "Select" and
"Edit". When a user clicks the "Select" link to select a row, the event
SelectedIndexChanged is triggered. When a user clicks the "Edit" link to
edit a row, the event RowEditing is triggered.

Hope this helps. If anything is unclear, please feel free to post here.

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 1 '06 #3
Walter thanks once again for your help.
Found a soultion.
The commandFields are fine they work as expected
Problem was I set the two commandfields to ShowSelectButton = true.
The view button was correct ShowSelectButton= true.
The edit button was incorrect should have been set to ShowEditButton = true.

These are properties of the commandfields.
They raise the same events now the autogenerate buttons generate, but now I
have a pretty Icon in each cell .
--
Life in the sun
"Walter Wang [MSFT]" wrote:
Hi,

Thank you for your post!

Based on my understanding, the SelectedIndexChanged event is occurred when
a row's Select button is clicked, it has nothing to do with which column is
clicked or selected.

You can set property AutoGenerateSelectButton="true" and
AutoGenerateEditButton="true" to generate two columns of "Select" and
"Edit". When a user clicks the "Select" link to select a row, the event
SelectedIndexChanged is triggered. When a user clicks the "Edit" link to
edit a row, the event RowEditing is triggered.

Hope this helps. If anything is unclear, please feel free to post here.

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 1 '06 #4
Thank you for your update.

Besides using <asp:CommandField> to add button fields, you can also use
<asp:ButtonField> to add custom button fields other than those built-in
commands. For these commands, you can use the RowCommand event to handle
their click event, and you can distinguish them by the event parameter
GridViewCommandEventArgs.CommandName property which is set when defining
those button fields. For more information, please refer to MSDN
documentation on GridView's RowCommand event.

Have a nice day.

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 1 '06 #5

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

Similar topics

3
by: theKirk | last post by:
using Visual Studio 2005 C# ASP.NET I know there has to be a simple way to do this....I want to use C# in a code behind for aspx. Populate a GridView from an xml file Add Fields to the...
6
by: Nalaka | last post by:
Hi, I have a gridView (grid1), which as a templateColumn. In the template column, I have put in a gridView (grid2) and a ObjectDataSource (objectDataSource2). Question is... How to I pass the...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
5
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens...
1
by: joechipubik | last post by:
I have a GridView in a FormView that has as its datasource a DataTable that is stored in the session cache. When I first load the page the GridView is displayed correctly, but on subsequent loads...
3
by: Jeff | last post by:
Hey asp.net 2.0 In the source I posted below, there is a GridView (look at the bottom of the script): <asp:GridView ID="gvwOnline" runat="server"> </asp:GridView> I'm trying to assign a...
2
by: antonyliu2002 | last post by:
I've been googling for some time, and could not find the solution to this problem. I am testing the paging feature of gridview. I have a very simple web form on which the user can select a few...
5
by: Andrew Robinson | last post by:
I am attempting to better automate a Pager Template within a GridView. I am succesfully skinning a Drop Down List withing my control (the DDL is added to my control). I correctly populate the item...
6
by: RobertTheProgrammer | last post by:
Hi folks, Here's a weird problem... I have a nested GridView setup (i.e. a GridView within a GridView), and within the nested GridView I have a DropDownList item which has the...
3
by: Peter | last post by:
I have a GridView which is populated by List<ofObjects> Does anyone have example of how to sort the columns of this GridView? I have found examples without DataSourceControl but these use...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.