How to get text of gridview buttonfield

G

Guest

I have a gridview. One of the columns is a buttonfield. I use the
datatextfield property of buttonfield to show my bound value as a hyperlink
in each buttonfield cell. I then want to get that text in the rowdatabound
event. I can get it easily for each boundfield cell but not for the
buttonfield. Please help. Thanks.
 
G

Guest

void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//use this syntax to get the text from the dataitem that was bound
to the grid
string myText = ((DataRowView)e.Row.DataItem)[FieldName].ToString ();
//use this syntax to get the text from the ViewState of the GridView
string myText2 =
((LinkButton)e.Row.Cells[ColNumWhereTheLinkIs].Controls[0]).Text;
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top