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

GridView template needs to set CommandArgument to row index

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 fine.
However, e.CommandArgument is an empty string, presumably because the
CommandArgument property of the ImageButtons is not set.

Is there some way, in the markup, to set the CommandArgument to the row
index?

<ItemTemplate>
<asp:ImageButton ID="btnSave" runat="server"
CommandName="Save" ImageUrl="~/Images/Diskette.gif"
CommandArgument="SOMETHING HERE" />&nbsp;&nbsp;
<asp:ImageButton ID="Email" runat="server"
CommandName="Email" ImageUrl="~/Images/Envelope.gif"
CommandArgument="SOMETHING HERE" />
</ItemTemplate>

TIA,

David

Aug 25 '06 #1
2 6010
Here is one example doing it in code:
http://msdn2.microsoft.com/en-us/lib...owcommand.aspx

It is set in RowCreated event.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

"David" <do**@translogisticsinc.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
>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 fine.
However, e.CommandArgument is an empty string, presumably because the
CommandArgument property of the ImageButtons is not set.

Is there some way, in the markup, to set the CommandArgument to the row
index?

<ItemTemplate>
<asp:ImageButton ID="btnSave" runat="server"
CommandName="Save" ImageUrl="~/Images/Diskette.gif"
CommandArgument="SOMETHING HERE" />&nbsp;&nbsp;
<asp:ImageButton ID="Email" runat="server"
CommandName="Email" ImageUrl="~/Images/Envelope.gif"
CommandArgument="SOMETHING HERE" />
</ItemTemplate>

TIA,

David

Aug 25 '06 #2
Thank you for your reply. I had already planned on doing it in the
RowCreated event. I was just hoping there was some way to do it in the
markup.

Thanks again.

David

Teemu Keiski wrote:
Here is one example doing it in code:
http://msdn2.microsoft.com/en-us/lib...owcommand.aspx

It is set in RowCreated event.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

"David" <do**@translogisticsinc.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
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 fine.
However, e.CommandArgument is an empty string, presumably because the
CommandArgument property of the ImageButtons is not set.

Is there some way, in the markup, to set the CommandArgument to the row
index?

<ItemTemplate>
<asp:ImageButton ID="btnSave" runat="server"
CommandName="Save" ImageUrl="~/Images/Diskette.gif"
CommandArgument="SOMETHING HERE" />&nbsp;&nbsp;
<asp:ImageButton ID="Email" runat="server"
CommandName="Email" ImageUrl="~/Images/Envelope.gif"
CommandArgument="SOMETHING HERE" />
</ItemTemplate>

TIA,

David
Aug 28 '06 #3

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

Similar topics

0
by: Kyle K. | last post by:
(Note: Windows XP Pro SP2 + Visual Studio .NET 2005 + SQL Server 2000) I have a GridView that is populated with data. That last 2 columns are button fields (image buttons) that have a CommandName...
2
by: cartmann | last post by:
Hi, I have a gridview with a template column. In the template column i have two commandbuttons. When clicking the buttons I enter the cmd_click event - but how do I read in which row the button...
3
by: | last post by:
Hi all, I am trying to have a linkbutton control with the commandname property set. However, when I invoke it, the CommandArgument property ends up coming to be blank. However, if I click on the...
0
by: mesut | last post by:
hit there, I have a problem getting the rownumbers when I use the template field <asp:button control. I don't get the rownumbers when I use this control. When I use a buttonfield control then I...
0
by: David Lozzi | last post by:
Howdy, I have a gridview with a linkbutton in a template column (code is below). When the linkbutton is clicked i want to display a little confirm right in the gridview to confirm deleting the...
4
by: Ken Fine | last post by:
I'm making an administrative interface that lists records in a GridView. For *each* row in the gridview, I would there to be two interface elements in addition to some information associated with...
3
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have a gridview with one of the columns as a template column with a button. When the user selects the button is there a way to get the row number in the button_Click event? Another one of...
7
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
I'm adding subheadings to a gridview. Each sub head has a few link buttons. I'm adding the controls in the rowdatabound event code follows: sorry about the length here. I have to be missing...
0
by: =?Utf-8?B?ZWdzZGFy?= | last post by:
Hi, I have created a second gridview when customer clicks on select link with this code: Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.