Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
how to select value on the basis of Label ID which is invisible in Grid view.
Posted 14-Dec-12 7:29am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can use DatakeyNames with ID in the gridview itself. and Grab the id in gridview event.
 
else
 
you can use the following:
Label ID = (Label)Gridview1.Rows[e.RowIndex].FindControl("labelid");
and access it using ID.text
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,
 
You can use a hidden field and bind the id value to the hidden field during the loading of the data to the grid.
 
<asp:hiddenfield id="hdnID" runat="Server" value="<%" xmlns:asp="#unknown">/></asp:hiddenfield>
 
In the code behind access the valus as
 
lblResult.Text = hdnID.Value;
 
Thanks
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 7,442
1 OriginalGriff 5,996
2 Peter Leow 4,292
3 CHill60 2,858
4 Mika Wendelius 2,850


Advertise | Privacy | Mobile
Web03 | 2.8.150224.1 | Last Updated 14 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100