Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing text on Select ButtonColumn in Grid...

Status
Not open for further replies.

Hokkie

MIS
Nov 21, 2001
77
NL
Hi,

In the ItemDataBound event of my datagrid, I want to change the text on the select ButtonColumn for some rows, depending on the value of some of the cells in that row. The text I want to put on the ButtonColumn is not always the same and also depends on those same values; basically it will say how many items are left if there are less than 10.

When I change the text on the ButtonColumn select cell, the selecting-property of that cell disappears. So, where an unchanged ButtonColumn cell would be a sort of 'hyperlink' that selects that particular row, the changed text will just be text and clicking it does not fire any events...

A workaround is to create an additional column in the table I use as a datasource and set the Textfield property of the select ButtonColumn to that column, but I was just wondering why the selecting-property would disappear. I use this to change the text property:

e.Item.Cells[0].Text = "## items left";

Ok, long story for a short question, but I am curious and have found nothing on google that addresses this situation. Any ideas here as to why the ButtonColumn seems to cease being a ButtonColumn??

cheers,
hokje


 
You have to get a reference to the button in the column since it is not a regular column but a type of template column. Once you get a reference to the button, then you can change the text and it should be fine.
 
Ok, thanks Jbenson001.

How do I get a reference to the button? I tried casting the e.Item.Controls[0] to a ButtonColumn but got an error.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top