aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Get Find control inside of gridview in rowdatabound event

Jun 18, 2012

In this article I will explain how to find controls (textbox, dropdownlist, checkbox,radio button etc..) in inside of gridview and how to get values from controls which is inside of gridview in rowdatabound condition in


In previous posts I explained many articles relating to
gridview now I will explain how to find or get values of controls which is inside of gridview in
Generally if we want to find or get value from controls which is inside of gridview in rowdatabound condition we will write code like this

protected void gvUserInfo_RowDataBound(object sender, GridViewRowEventArgs e)
DropDownList ddl = (DropDownList)gvUserInfo.FindControl("yourControlName");
string ddlValue = ddl.SelectedItem.Value;
TextBox txtUserInfo = (TextBox) gvUserInfo.FindControl("yourControlName");
string strValue = txtUserInfo.Text;
Suppose if we have controls in each row of gridview then we need find each row of controls for that we need to write a code like this

protected void gvUserInfo_RowDataBound(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.DataRow)
DropDownList ddl = (DropDownList)e.Row.FindControl("ddlCity");
int CountryId = Convert.ToInt32(ddl.SelectedItem);
For sample or example check below posts

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


Anonymous said...

you are using dropdown list can u please show in gridview

Anonymous said...

great,, thanks,,,
work for me.. thanks a loott

Unknown said...

sir can you provide a demo for nested gridview And load data into it from sql in C#?

Anonymous said...

thanks.Nice one

Anonymous said...

Hi suresh i want to find span id in row databond is it possible to find that

Dhaval Vaghani said...


You can get the span id in rowdatabound event by defining control there as HtmlGenericControl.

var spanid = e.item.FindControl("") as HtmlGenericControl

Sudhakar said...

want to use multiple fileupload control againtst each row inside gridview and save files to database on Submitt click....please help

Anonymous said...

it is a wonderful site. please keep uploading new articles.
have a great time.

Anonymous said...


Unknown said...


Unknown said...

i want the value of textbox in rowdatabound event but the control is on a page, not inside the gridview.....

pabitra@microsoftresearch said...

Label bill = (Label)e.Row.FindControl("lbl_bill");
nice sir

Pintu Mali said...

I want to make invoice system

plz suggest me how i can make ?

window based C#

Unknown said...

Great coding

Unknown said...

Hi guys and suresh ,I need one help im getting one error .This is an application error.
The error is

Unable to find control id 'TextBox1' referenced by the 'ControlToValidate' property of 'RangeFieldValidator1".

how do i solve this please give me some suggestions do i need to refer this id in master page.

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.