Click here to Skip to main content
Click here to Skip to main content

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

Introduction

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
Next
If myText <> String.Empty Then
    ScriptManager.RegisterStartupScript(Me.Page, Me.Page.GetType(), _
	"message", "alert('" & myText & "');", True)
End If

License

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

Comments and Discussions

 
GeneralA Tip/Trick!!! PinmentorSandeep Mewara3-Jul-10 20:48 
GeneralComments PinmvpMd. Marufuzzaman3-Jul-10 20:24 
GeneralNot an article PinmemberJohn Simmons / outlaw programmer3-Jul-10 11:51 

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

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

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