Created
March 1, 2012 10:36
-
-
Save pranabmitra/1948977 to your computer and use it in GitHub Desktop.
Get Value from Gridview in Gridview RowCommand Event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<asp:TemplateField HeaderText="Account No"> | |
<ItemTemplate> | |
<asp:Label ID="lblAccountNo" runat="server" Text="<%# Bind('ReceivedItemInfo_AccountNo') %>"></asp:Label> | |
<asp:HiddenField ID="hdnIsFlag" Value="<%# Bind('ReceivedItemInfo_IsFlag') %>" runat="server" /> | |
<asp:HiddenField ID="hdnPreviousState" Value="<%# Bind('ReceivedItemInfo_PreviousState') %>" runat="server" /> | |
</ItemTemplate> | |
</asp:TemplateField> | |
protected void gridViewReceivedInfo_RowCommand(object sender, GridViewCommandEventArgs e) | |
{ | |
GridViewRow row = (GridViewRow)(((Button)e.CommandSource).NamingContainer); | |
HiddenField hdnPreviousState = (HiddenField)row.Cells[1].FindControl("hdnPreviousState"); | |
string previousState = hdnPreviousState.Value; | |
} |
muchas gracias!
Thank you too much
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for solution,
Even we can optimize it as
string previousState = ((HiddenField)((GridViewRow)(((Button)e.CommandSource).NamingContainer)).FindControl("hdnPreviousState")).Value;