C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » ASP.NET GridView »

getting value of invisible boundfield in gridview - (vbscript)


Posted Date: 07 Oct 2009    Resource Type: Code Snippets    Category: ASP.NET GridView
Author: RamanathanMember Level: Bronze    
Rating: 1 out of 5Points: 5



I searched the net a lot for this task. But no direct and clear help I got. But I have figured it out from the information I have gathered.

I would like to share with those who are looking for the same.

We want to retrieve the values of two databound fileds
"usernm" visible = true
"userno" visible = false

set the property (in design view)

gridview.datakeynames as "userno,usernm"


For runtime (in the page load event)

gridview1.datakeynames = "userno,usernm".split(",")
(split is used to make it 1 - dimensional array)

dc = New BoundField
strName = "userno"
dc.DataField = strName
dc.Visible = False
GridView1.Columns.Add(dc)
GridView1.DataKeyNames = "userno".Split(" ") and....usernm too.


We can retrieve the value of the invisible field as follow. ( I used in rowcommand event)

Dim Userno As String
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
Userno = GridView1.DataKeys(index).Item(0).ToString
Label2.Text = Userno

Hope it helps those who is search of it.



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Value of invisible boundfield  .  Hiddenfiled in gridview  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Generic Code
Previous Resource: Export GridView To Excel/word Using asp.net
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET GridView


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use