473,320 Members | 1,936 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,320 software developers and data experts.

Row Index in RowCommand event handler

I have a gridview that has a button column and a template column with another
button in it. When I click on the button column button I can get the row
index in the event handler for the CommandArgument parameter. However when I
click on the template column button the CommandArgument parameter is "".

How can I get the row index when a user clicks on a button in a template
column?

Thanks,
James
Nov 9 '07 #1
3 9772
Hi,

I guess you have to put it inthe Command argument :)
What I usually do is put the "id" or key inthe ComandArgument. I have never
put the column index. I'mpretty sure you can get a hold of it using binding.
Otherwise you have to use ItemDataBound method.

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"James Lennon" <Ja*********@discussions.microsoft.comwrote in message
news:7E**********************************@microsof t.com...
>I have a gridview that has a button column and a template column with
another
button in it. When I click on the button column button I can get the row
index in the event handler for the CommandArgument parameter. However
when I
click on the template column button the CommandArgument parameter is "".

How can I get the row index when a user clicks on a button in a template
column?

Thanks,
James

Nov 9 '07 #2
How would you set the command argument to an ID or Key? I am simply binding
to a datatable.

James

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

I guess you have to put it inthe Command argument :)
What I usually do is put the "id" or key inthe ComandArgument. I have never
put the column index. I'mpretty sure you can get a hold of it using binding.
Otherwise you have to use ItemDataBound method.

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"James Lennon" <Ja*********@discussions.microsoft.comwrote in message
news:7E**********************************@microsof t.com...
I have a gridview that has a button column and a template column with
another
button in it. When I click on the button column button I can get the row
index in the event handler for the CommandArgument parameter. However
when I
click on the template column button the CommandArgument parameter is "".

How can I get the row index when a user clicks on a button in a template
column?

Thanks,
James


Nov 13 '07 #3
I found the solution there is two ways to set it

1) <asp:Button (...) CommandArgument="<%# Container.DataItemIndex %>" />
2) In the row created event handler.


"James Lennon" wrote:
I have a gridview that has a button column and a template column with another
button in it. When I click on the button column button I can get the row
index in the event handler for the CommandArgument parameter. However when I
click on the template column button the CommandArgument parameter is "".

How can I get the row index when a user clicks on a button in a template
column?

Thanks,
James
Nov 13 '07 #4

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

Similar topics

1
by: Zule | last post by:
Hi, I am creating a Composite Control within which I have a GridView. In this GridView, I have three TemplateFields, the last one being a template with a LinkButton which is meant to be clicked...
6
by: Kevin Attard | last post by:
I am using a GridView inside a UserControl which has a template column for deleting the rows. Before databinding the gridview i am attaching the RowCommand and RowDataBound event. I am using the...
2
by: David | last post by:
I have a template field in a GridView that contains two ImageButtons. When the user clicks one of the buttons, the GridView's RowCommand event is fired and I can get the CommandName. All that is...
1
by: jobs | last post by:
CommandArgument does not contain row index when command under Templatefield of- Gridview It appears CommandArgument passed to the rowcommand event does not contain row index when the command is...
7
by: =?Utf-8?B?cGF0cmlja2RyZA==?= | last post by:
Hi all! I have a gridview inside a datagrid (nested) for which (gridview) the rowcommand is not raised in order to delete a row from the grid! I also tried OnRowCommand="method", didn't work...
3
by: Nathan Sokalski | last post by:
I have a GridView with a ButtonField. In the RowCommand I need to use the value of one of the fields used in that row. I am having trouble doing this, so I would appreciate it if someone could help...
0
by: =?Utf-8?B?cmxt?= | last post by:
I have a gridview updating every 5 seconds. There are several DataKeys declared which I access successfully in the RowDataBound event. However, in the ROwCommand event the count of the DataKeys...
0
by: =?Utf-8?B?YmVuamk=?= | last post by:
Hi, I've got a gridview that I bind programmatically to a view of a typed dataset. One column has a command button, and in the RowCreated event, I test to see if it's a DataRow, and if it is, I...
0
by: progman417 | last post by:
Hello, I've got a Web User Control containing a gridview with a "select record" button on each row. When the user clicks the button I want to call an event handler in the main page. My...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.