Hi i m using GridView with hovermenu and i want that when we click on edit button then we get TextBox to write in Gridview and also i get error when click on edit for e.commandArgument is null so please give me code for this both
views:
444answers:
2
A:
Give your edit button command name like this,
<asp:LinkButton ID="LinkEdit" runat="server"
CausesValidation="false" CommandName="EditRow" Text="Edit"></asp:LinkButton>
and in RowCommand
event of ur gridview
if (e.CommandName == "EditRow")
{
TextBox tbx = (TextBox)gridCategory.Rows[Convert.ToInt32(e.CommandArgument)].FindControl("UrTxtID");
}
Any how its really difficult to tell what you are doing wrong without seeing your code..
EDIT:
i think you need to set CommandArgument='<%# Container.DataItemIndex %>'
in your edit button...
Pandiya Chendur
2010-03-27 06:58:02
@Pandiya Chendur, Code is good but i get e.CommandArgument = ""so again it gives error of FormatException
Khilen
2010-03-27 08:37:07
@khilen can you post ur code or ur exception...
Pandiya Chendur
2010-03-27 09:07:41
@khilen look at my edited answer...
Pandiya Chendur
2010-03-27 09:10:33
@khilen have it worked...
Pandiya Chendur
2010-03-30 06:40:16
A:
I ran across your post while searching for a way to get the current row in a gridview rowcommand event.
I also ran across this link and thought I'd share:
http://ranafaisal.wordpress.com/2008/03/31/how-to-get-the-current-row-in-gridview-row-command-event/
This solved my problem and seems very clean.
Thanks,
Mike =:-)
Michael McCarty
2010-05-31 09:50:28