Click here to Skip to main content
13,260,383 members (43,717 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


2 bookmarked
Posted 3 Jul 2010

Find Text Inside Gridivew Cell

, 3 Jul 2010
Rate this:
Please Sign up or sign in to vote.
Get the text present inside tablecell in both visible or hidden mode using VB.NET


This article is used to demonstrate to the user how to get the text present on TableCell inside a GridView. The basic idea is bind your datavalue inside a server side control and finally search for the control and get text from it. The process I have shown is also for a case when a particular column is hidden.

Using the Code

In this sample application, there are two buttons, a button for finding text at column "Data Text" and a button that shows/hides data present under header "Name" and "Data Text".

The button for show/hide certain columns has the following click() event:

 // Button click event for show/hide columns.
Protected Sub btnShowHide_Click(ByVal sender As Object, _
	ByVal e As System.EventArgs) Handles btnShowHide.Click
 gvPopulate.Columns(0).Visible = Not gvPopulate.Columns(0).Visible
 gvPopulate.Columns(2).Visible = Not gvPopulate.Columns(2).Visible
End Sub

Similarly, the button for finding the text present inside a cell have the following click() event:

Dim myText As String = String.Empty
For Each row As GridViewRow In gvPopulate.Rows
    Dim chkSelect As CheckBox = CType(row.FindControl("chkSelectName"), CheckBox)
    If chkSelect.Checked Then
        myText &= CType(row.FindControl("ltrDataText"), Literal).Text & " "
    End If
If myText <> String.Empty Then
    ScriptManager.RegisterStartupScript(Me.Page, Me.Page.GetType(), _
	"message", "alert('" & myText & "');", True)
End If


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


About the Author

No Biography provided

You may also be interested in...

Comments and Discussions

GeneralA Tip/Trick!!! Pin
Sandeep Mewara3-Jul-10 21:48
mentorSandeep Mewara3-Jul-10 21:48 
GeneralComments Pin
Md. Marufuzzaman3-Jul-10 21:24
mvpMd. Marufuzzaman3-Jul-10 21:24 
GeneralNot an article Pin
John Simmons / outlaw programmer3-Jul-10 12:51
memberJohn Simmons / outlaw programmer3-Jul-10 12:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.171114.1 | Last Updated 3 Jul 2010
Article Copyright 2010 by prashant chalise
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid