Change grid button text at runtime

  • Thread starter Thread starter Charlie Dison
  • Start date Start date
C

Charlie Dison

Hi there,
How can I change the caption of a button in a grid at runtime? I seem
to be able to change the header text in the column where the button appears
but not the button caption. Thanks in advance.
 
Hi Charlie,

Can you post the HTML code for your DataGrid? With the code, we can get a
idea on how you create the column and header. This can help to determine
how to achieve the issue.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Hi Luke
I am creating the grid at design time. I simply go into propert
builder, click on columns, and add a button column. The button type is
pushbutton. Is there a way I can set the caption (text) of the push butto
at runtime? Sometimes I want it to say select and other times I want it t
say edit
 
Hi Charlie,

Regarding the issue, you may try following code:

foreach(DataGridItem DemoGridItem in DataGrid1.Items)
{
Button myButton=
(Button)DemoGridItem.Cells[CellIndex].Controls[ControlIndex];
myButton.Text="Select";

}

CellIndex and ControlIndex are zero based integer. You need to change them
to the actural value based on the button's position in the datagrid.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top