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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change button name in a column

Status
Not open for further replies.

abds

Programmer
Dec 13, 2000
46
0
0
US
I have a working datagrid with good records (status = 1) showing normally, and bad records (status<>1) shown in red.
I have a button column saying &quot;delete&quot; for all records.
I want it to say &quot;delete&quot; for good records, and &quot;undelete&quot; for bad records.
How do I do this?
TIA
Phil

We are drowning in data, but we are starving for information.
 
It's sure doable but using the TemplateColumn instead of ButtonColumn. I assume that &quot;status&quot; is one of the fields in a recordset you bind the grid to and it's an integer:
Code:
<asp:DataGrid id=&quot;myGrid&quot;>
 <Columns>
   <asp:TemplateColumn>
     <ItemTemplate>
       <asp:Button Runat=server Text='<%# setText((int)DataBinder.Eval(Container.DataItem, &quot;status&quot;)) %>' />
     </ItemTemplate>
   </asp:TemplateColumn>
 </Columns>
</asp:DataGrid>

//code behind:
public string setText(int status)
{
  string buttonText = &quot;delete&quot;;
  if(status != 1)
  {
    buttonText = &quot;undelete&quot;;
  }
  return buttonText;
}

 
Works beautifully LV. Thank you.
Phil

We are drowning in data, but we are starving for information.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top