Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 23, 2013 12:48 PM by oned_gk
Jan 23, 2013 11:33 AM|LINK
I am building an application for tickets using a gridview. Each row has an option to edit the ticket or delete it. I did it by adding 2 selected button on each row.
Now, the issue is that I cannot tell which button is clicked since they both get me to the same event which is onselectedindexchanged.
They dont have any ID so I cannot run in a loop and find the ID and they dont return the text with cell.text since I got null on both buttons.
How can I retrive information on which selected button was clicked in a specific row ? It will be enough to know the column name but how do I do that ?
Jan 23, 2013 11:36 AM|LINK
you can pass the commandargument..let me get you an example.
Jan 23, 2013 11:40 AM|LINK
for your use CommandName should be sufficient
<asp:ButtonField ButtonType="Link" CommandName="Approval" Text="Approve" />
<asp:ButtonField ButtonType="Link" CommandName="Reject" Text="Reject" />
CS File ->
if (e.CommandName == "Approval")
if (e.CommandName == "Reject")
Jan 23, 2013 11:44 AM|LINK
Check this url, ypu will find your answer here
Jan 23, 2013 11:51 AM|LINK
Your answer would be gread if I was using ButtonField, but I am using Commandfield and CommandName is not valid attribute for this type. Any other suggestion ?
Jan 23, 2013 11:55 AM|LINK
Jan 23, 2013 12:03 PM|LINK
So I need to change my code to template instead of commandfield....I guess this is what I will do if I have no other choice.
Jan 23, 2013 12:34 PM|LINK
Ok, it is working fine.... Can you explain to me what this do:
CommandArgument='<%# Container.DataItemIndex %>' ?
Jan 23, 2013 12:48 PM|LINK
When using rowcommand you can pass value using CommandArgument. For example CommandArgument="abc".
Your sample will set commandargument property value using rowindex value.
You can also make row namber using label, set text property : text = '<%# Container.DataItemIndex + 1 %>'